English-ising Code
OK you don't need to be illiterate to see that VB.net is a Programming Language, that isn't shy about it verbosity of word. So I thought let's go crazy and see how close to Written English I can make it.
So I started with simple task. English-ify the follow.
What you really want to do is say Is value between lower and upper?
Example 2: IsEqualTo
To see how this English-fication was/is created, pop over to my GitHub Repo: Englishify
NuGet: Englishify
Future
I've got a working implementation that Englishify numbers, via the digits.
Dim i As Integer = Number.Negative.One.Two.Three ' i <- -123 '
It current restricted to Integer Values only, it eventually will have floating point numbers as well (Double).
Some version in the future will enable you express numbers like Dim i2 As Integer = Number.One.Hundred.And.Twenty.Three.
OK you don't need to be illiterate to see that VB.net is a Programming Language, that isn't shy about it verbosity of word. So I thought let's go crazy and see how close to Written English I can make it.
So I started with simple task. English-ify the follow.
Dim value = 3 Dim lower = 0 Dim upper = 10 Dim result = "" If lower <= value AndAlso value <= upper Then result = "Yes" Else result = "No" End If
What you really want to do is say Is value between lower and upper?
If value.IsBetween(lower).And(upper) Then result = "Yes" Else result = "No" End If
Example 2: IsEqualTo
If (value).IsEqualTo(lower).Or(upper) Then Console.WriteLine("Yes")
To see how this English-fication was/is created, pop over to my GitHub Repo: Englishify
NuGet: Englishify
Future
I've got a working implementation that Englishify numbers, via the digits.
Dim i As Integer = Number.Negative.One.Two.Three ' i <- -123 '
It current restricted to Integer Values only, it eventually will have floating point numbers as well (Double).
Some version in the future will enable you express numbers like Dim i2 As Integer = Number.One.Hundred.And.Twenty.Three.
5 Comments On This Entry
Page 1 of 1
37Liion
07 May 2012 - 12:06 PM
I don't mean to come off as extremely pessimistic.. but this is gross.
We're writing for the computer and each other, not for our grade school English teachers.
At best create a helper method/macro:
Until code dictation becomes the norm, I don't see much use creating a vague .And(integer) method, or an IsBetween(integer) method that takes one argument.
value.IsBetween(lower).And(upper)
We're writing for the computer and each other, not for our grade school English teachers.
At best create a helper method/macro:
(value).IsBetween(lower,upper) // or IsOrdered(lower, value, upper)
Until code dictation becomes the norm, I don't see much use creating a vague .And(integer) method, or an IsBetween(integer) method that takes one argument.
37Liion
07 May 2012 - 04:12 PM
AdamSpeight2008, on 07 May 2012 - 02:47 PM, said:
The .And method is not vague
For example
You don't say
when you want to say
In Englishified Code this would be
now if do . you get access to the .Add method.
For example
You don't say
If Zero is Less Or Equal to value And Also value is Less or Equal to Ten Then
when you want to say
If value Is Between Zero and Nine
In Englishified Code this would be
If value.IsBetween(0)(Inclusive is the Default)
now if do . you get access to the .Add method.
Inclusive is the Default what?
What happens when you don't append .And(value) to .IsBetween(value)?
Is what you mean to say is that .And(0) is implicitly default?
What is the return type of IsBetween that .And can be called on?
Where is IsBetween implemented?
I understand that it was just a brainstorm and not a fully fleshed out idea.
And I don't mean to attack you.
Its just that particular line is an eyesore in my opinion.
I suppose one more niche could be filled as such: value.IsBetween(lower.And(upper)) such that the result of lower.And(upper)) is two a argument tuple of sorts..
Page 1 of 1
|
|



5 Comments








|