Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Гипотеза Сепира — Уорфа и VB.Net

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Гипотеза Сепира — Уорфа и VB.Net

Avatar for xeningem

xeningem

May 30, 2017

Other Decks in Programming

Transcript

  1. Гипотеза лингвистической относительности Гипотеза лингвистической относительности предполагает, что структура языка

    влияет на мировосприятие и воззрения его носителей, а также на их когнитивные процессы. Лингвистическая относительность широко известна как гипотеза Сепира — Уорфа. Выделяют две формулировки этой гипотезы: 1. Строгая версия: язык определяет мышление, и, соответственно, лингвистические категории ограничивают и определяют когнитивные категории. 2. Мягкая версия: мышление наряду с лингвистическими категориями определяет влияние традиций и некоторые виды неязыкового поведения. (спасибо, Википедия) 2
  2. Отличия явные “Многословность”: If condition Then ' condition is true

    ElseIf othercondition Then ' condition is false and othercondition is true Else ' condition and othercondition false End If For i As Integer = number To 0 Step -1 ' loops from number down to zero Next 4
  3. Отличия явные Регистронезависимые имена Dim i = 0 Dim I

    = 1 <- Error BC30288 Local variable 'I' is already declared in the current block. Параметров это не касается, так что особо проблем не доставляет Class Customer End Class Class Example Public Sub F(customer as Customer) End Sub End Class 5
  4. Отличия явные Другие ключевые слова • Friend vs internal -

    access modifiers allowing inter-class but not inter-assembly reference, except for friend assemblies • Me vs this - a self-reference to the current object instance • MustInherit vs abstract - prevents a class from being directly instantiated, and forces consumers to create object references to only derived classes • MustOverride vs abstract - for forcing derived classes to override this method • MyBase vs base - for referring to the base class from which the current class is derived • NotInheritable vs sealed - for declaring classes that may not be inherited • NotOverridable vs sealed - for declaring methods that may not be overridden by derived classes • Overridable vs virtual - declares a method as being able to be overridden in derived classes • Shared vs static - for declaring methods that do not require an explicit instance of an object А ещё: • Function/Sub - for method signature • Structure vs struct - for declaring value types • Implements / Inherits - when implements interface / inherits class • etc. 6
  5. В общем изменений всего ничего И конвертеров полным полно, в

    том числе и бесплатных. Dim shape As Object Dim fileName = "FileName.jpg" If Word.WdWrapType.wdWrapInline = wrap Then shape = range.Document.InlineShapes.AddPicture(FileName:=image.GetFileName(), LinkToFile:=False, SaveWithDocument:=True, Range:=range) Else shape = range.Document.Shapes.AddPicture(FileName:=image.GetFileName(), LinkToFile:=False, SaveWithDocument:=True, Anchor:=range) End If shape.LockAspectRatio = True If shape.Width > shape.Height * 2 Then shape.Height = minsize ElseIf shape.Width * 2 < shape.Height Then shape.Width = minsize End If 7
  6. В общем изменений всего ничего И конвертеров полным полно, в

    том числе и бесплатных. object shape = null; string filename = "FileName.jpg"; if (Microsoft.Office.Interop.Word.WdWrapType.wdWrapInline == wrap){ shape = range.Document.InlineShapes.AddPicture(FileName: filename, LinkToFile: false, SaveWithDocument: true); } else { shape = range.Document.Shapes.AddPicture(FileName: image.GetFileName(), LinkToFile: false); } shape.LockAspectRatio = true; if (shape.Width > shape.Height * 2) { shape.Height = minsize; } else if (shape.Width * 2 < shape.Height) { shape.Width = minsize; } 8
  7. Вам что-то хотят этим сказать • у Visual Basic .Net

    богатая история, и масса людей, которые привыкли писать так, как писали много лет назад • компилятор, по умолчанию, будет делать ОЧЕНЬ много того, к чему в static typed языках не привыкли • и по умолчанию даже не будет говорить о ситуациях, который в C# были бы однозначной ошибкой 9
  8. “А что, так можно было?” Dim i = "1" Dim

    j = 1 If i = j Then 'Compiler does cast and compare between i and j MsgBox("Avoid using, but this message will appear!") End If Пример late binding: Dim test test = "Hello world" Console.WriteLine(test.length) test = 42 Console.WriteLine(test / 6) 10
  9. Необычное приведение типов Public Class InheritExample Interface IExample End Interface

    Public Class MyExample Implements IExample End Class Public Sub Run(example as MyExample) End Sub Public Sub Test() Dim value as IExample = New MyExample() Run(value) End Sub End Class 11
  10. Что с этим можно сделать? Если хочется, чтобы было “как

    в C#” в смысле работы с типами: Properties -> Compile -> Option strict -> On Либо, если проект перестанет от этого собираться - Custom & Notification Warning Стандартные рекомендации: Treat all warnings as errors 12