- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Only if you've allowed a subclass of the PhoneNumber class to be AmericanPhoneNumber ... hang on, that can't be the correct approach - where's me gang-of-four, I feel a Pattern coming on ...
Admin
There's no reason for the PhoneNumber class to know how to validate all these parts. When you're looking at the PhoneNumber class you can easily see what it does without getting into the details of validating an area code, and if you want to see that you just look at the AreaCode class.
Admin
Admin
ThisFunctionReturnsTrueIfInputParameterArgumentIsOneAndFalseIfInputParameterArgumentIsZero(int InputParameterArgument) {}
Admin
Your mom had to call Maury because she was quite the gang-of-four whore. The worst thing is you still don't know who's your daddy, and you got to see four dudes dance a celebratory jig.
Admin
Ah, I thought you were using "properties" as a general description for class attributes -- I wasn't aware that Python had a property keyword. I still have a hard time understanding the disagreement expressed at having some unneeded but trivial get/set functions, and how this is worse than having code use multiple ways of accessing a member variable in the same way. The difference between obj.setVar() and obj.var isn't clear without looking through the class file. The "property" keyword seems like a get out of jail free card -- it shouldn't be part of the plan, but it's very handy when you need it.
Maybe as I think about it more, I'll see the light that you see. In any case, thank you for taking the time to explain.
Admin
What is "frist", and which purpose did your post serve?
Admin
It scares me that I had to get half way down page two of the comments before reading a comment by someone with a brain.
Admin
Perhaps he expected validation checking to be more complicated, but it didn't end up that way.
Admin
if (NoActivityTypesAreAttachedToThisEvent(activityTypes)) return TrueBecauseThereAreNoActivityTypesToFilterOnThisEvent();
The Because... stuff is implicit in the fact that it is being done as a result of the test.
The only thing that could possibly induce me to change my opinion about this code is if the original author gave a different reason (and I would still find it very hard to believe).
Admin
And in that case, changing what the function does so it no longer agrees with the name should also be done with a similar amount of caution.
Adding some logging code to a "GetTransaction" method is fine, adding some validation is probably fine, and neither require a name change. If you're adding something which requires a name change, you're back in 'serious problems' territory.
Admin
Re: Self Documenting 2012-05-02 13:40 • by Jay
That's why the PhoneNumber class needs to be subclassed into AmericanPhoneNumber, BritishPhoneNumber, RussianPhoneNumber, etc.
===========================
NO NO NO
What about Skype?
You need a VoiceCommunicationsFactoryFactoryFactory returning an InternationalPhoneNumberFactoryFactory returning a PhoneNumberFactory, returning a PhoneNumber object.
Yeah, that's a good start.
Admin
Three things could be at play here
But its probably #1.
Admin
What does a 50 characters identifier has to do with memory? Much less performance?
Compiler theory indeed....
Admin
I believe it originated on Slashdot. At least, that's the first place I saw it, although there may have evolved elsewhere, or evolved multiple times in parallel.
Whenever a new article would go up, some lamer would try to claim "First post!" in the comments section, without adding anything to the conversation. On Slashdot, I believe they started moving such comments randomly down the page, so the next step naturally was to mis-spell it, leading to "frist post" or "frost pist" or any other tortured locutions.
On FARK, the phrase "first post" gets turned into "boobies", and "last post" gets turned into "wieners", if I recall correctly. Its filter was inspired by similar problems.
Admin
For interpreted code (remember BASIC?), it ate up your variable store. Depending on your flavor of BASIC, it could also lead to lower program speeds for variable lookup.
For compiled languages, shorter variables and terser comments lead to smaller source files and therefore faster floppy disk access. (Remember those?) I'm always surprised how large my source files are, and then I remember I use spaces instead of tabs, have full-paragraph comments when needed, and write things out long-hand when it helps clarity.
When I look at a floppy's worth of source code from 30 years ago, I think to myself "wow, that's terse." And then I realize "But if it were less terse, the source probably wouldn't have fit on that floppy alongside the executable."
Admin
That's true these days. There was a time not that long ago when such a loquacious program might not fit cleanly in the system memory, though, or would fill your floppy prematurely. I have written compiled programs on an Apple ][, where the computer had 128K and the floppy was only 140K.
One valid criticism against such verbosity is that my ability to read and discriminate between strings falls off quickly with length. If faced with two long identifiers that differ only in one word in the middle, it's sometimes difficult to keep them straight.
Admin
Admin
Admin
Python has a few fairly powerful mechanisms like that. Another interesting one is the decorator system. A decoration is just you telling the compiler to pass the decorated function as an argument to a decorator, and binding the return value of such a call to the decorated name. A decorator is just a function, only that it expects a callable object (say, a function) as an argument, and should return a yet another callable object. The latter can wrap the invocation of the former in some clever way -- say, by building up a property object. This is why property getters/setters/deleters can be just as well declared by using decorators.
Here's a pretty example from StackOverflow:
Admin
Admin
What have identifiers to do with performance.
Admin
Don't feed the trolls. He's a Web 2.0/Facebook/iPad kid imposing a Real Programmer who uses Real Compilers.
Admin
To be able to do this, the names of the attributes and methods must be present in the runtime environment - the compiler will not erase them!
You can use byte code obfuscators to replace your long identifiers with shorter ones, but reflection will not work for the obfuscated code.
Admin
bling blong blang, this isn't spam...
TheOnlyProblemWithThisIsThatAfterThreeToFourWordsTheReadabilityOfAMethodIsCompletelyDestroyedOhAndReturnTrue();
Admin
Looks like COBOL to me!!
Admin
Most languages implement message digests (and crypto functions) like this, because they're designed to be fed input in chunks. Consider generating a hash of a 4.7GB DVD ISO. Do you want to feed all 4.7GB at once to your hash function?
Admin
return "Fail";
Admin
The rule to always encapsulate your field is there because there is a need to change without propagating to client, and the rule is there unchanged.
In C++, if you exposed a field, and then some client depended on it, there is no way you can change that to a property without touching client code. So you better write the accessor methods.
In C#, with the property keyword, make life easier. When code is changed from a field to a property, client code does not need to change, but they need to be re-compiled. To make life easier, it is better to expose as property to begin with.
In Python, it is possible now. No code change, no recompile.
Still, the rule doesn't quite change. We should always encapsulate the field to make it possible to change, it is just that the authoring needed to accomplish this changed.
The key is to keep the capability to add logic at field access.
Admin
You're both doing it wrong. Anyone who creates a class for a phone number should stick to astronaut architecting at home, and stay away from production code.
Admin
I remember when engineers built bridges, and programmers wrote code.
Admin
I was always told not to rely on remembering, but to use comments. "I'm going to get some tea now."
Admin
thanks for info
Addendum 2024-08-12 14:30: Hello everyone, just a quick tip from me. I found this fantastic service that writes essays on request and doesn’t cost much. They delivered https://essaybox.org/samples/ my essay on time and it was exactly what I needed. If you're looking for a reliable and affordable option, I definitely recommend them. Give it a shot!