|
"Training" is usually something you can only do in your free time, during the times you should be sleeping. At work you have to deliver stuff.
If you have a limited amount of time to deliver something that works and you're not yet quite experienced (and without any formal education on software development), then this sort of stuff happens.
It's not pretty but it works... for now...
Giraffes are not real.
|
|
|
|
|
So.. is the actual logic implemented in a costructor? post is out of scope for the rest of the world unless the code you have posted is incomplete.
Greetings - Jacek
|
|
|
|
|
Switch statements in Java didn't support strings as arguments until recently. Objective C still doesn't. So no training required
"You get that on the big jobs."
|
|
|
|
|
In Java, I'd use an Enum [^].
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Below that if-else if-else block, there must be some more lines like:
ResultObject res = post.DoSomething();
And someone complains then:
"Why does it not compile!!!"
|
|
|
|
|
He forgot to wrap each line in a try catch block! o_O
|
|
|
|
|
I have done things like this in the past, when I wanted to give me or other developers a hint for a possible later change. E.g. The "Name" to "2nd Parameter" correspondence could be just by chance or a quick first implementation. What I mean is: maybe "2nd Parameter" has to be localized or mapped later. If you would shorten the code with a direct assignment, I'd assume as a maintenance developer that "Name" always holds a valid "2nd Parameter to IngGenInvPs constructor. And this is maybe not true.
This code is not good for other reasons (use switch, use enum, others mentioned it), but not necessarily for the obvious redundance.
|
|
|
|
|
Today while reviewing one of the code, i found this chunk
class MyClass
{
private int m_SomeValue;
public int SomeValue
{
get { return m_SomeValue;}
}
public void SomeMethod()
{
var value = GetValue();
}
private int GetValue()
{
return SomeValue;
}
}
At first i started to think is there any catch behind this style. after few mins, i found its lame to write this way and finally it was admitted
|
|
|
|
|
I think the code is attempting to do something like this:
public int SomeValue {get; private set;}
|
|
|
|
|
Well nope, but still there wasnt a method needed to access/retrieve a instance member value
|
|
|
|
|
It's called "double encapsulation"! Wrap your field in a property, then wrap the property in a method! It will be even more object-oriented that way!
|
|
|
|
|
lol i bet it is!!
|
|
|
|
|
And don't forget to declare both the field and the property as private. Otherwise other bad programmers might accidentally access them.
|
|
|
|
|
Bit hacks[^]
For example: Round up to the next highest power of 2:
unsigned int v;
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
This makes my previous code soooo lame (Math.Pow(2,Math.Log(v,2)+1)) or sth like this).
Greetings - Jacek
|
|
|
|
|
|
|
I recently started working at a large corporation that transitioned from a waterfall to an agile approach to software development about 2 years ago. As a part of the transition, developers who never fully understood test-driven development decided to start writing unit tests for their code to make it feel more agile.
The results of their efforts are hundreds of unit tests with no clear purpose, goal, naming conventions, or coding standards. While trying to wrap my head around what possible benefit the unit tests offer, the best thing I can say about them is that they prove that random chunks of production code in private and public methods do the same thing as the unit tests which duplicate their logic whenever the constants specified in the unit tests match the values that haven't changed in the DEV database that they never mocked and the database connections and web services don't time out on them.
I guess, in some abstract sense, running these unit tests could provide some benefit to the system, but we could improve the benefits by ignoring the unit tests and hiring a witch doctor to stand next to the source control server, sense the code's ethereal energy, and tell us if the code feels cursed or not.
Know any witch doctors looking for employment?
|
|
|
|
|
Perhaps you could set the server on a nice, comfortable couch and have a psychologist discuss the "daddy issues" with the code, due to inept "parent" programmers..?
Same thing.
|
|
|
|
|
jesarg wrote: but we could improve the benefits by ignoring the unit tests and hiring a witch doctor to stand next to the source control server, sense the code's ethereal energy, and tell us if the code feels cursed or not.
Just along for the ride.
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011) "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)
"It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)
|
|
|
|
|
jesarg wrote: stand next to the source control server, sense the code's ethereal energy, and tell us if the code feels cursed or not.
I didn't know it was a recognised technique - I've been doing my testing that way for years...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
jesarg wrote: hiring a witch doctor to stand next to the source control server Hmm. I administer a number of SourceSafe data bases. Maybe sacrificing small animals is what I've been missing...
Software Zen: delete this;
|
|
|
|
|
I only know a lazy cargo cult Java team. They turn everything into a hollow useless ritual that's not worth the work you put into it. They also wanted me to write unit tests. The problem was that they were far too agile to provide any specifications about what might be correct and what is not correct. To be precise, they were not able to come up with any specifications at all.
So I was creative and tested everything that might possibly go wrong that came to my mind. The result was that practically all the tests failed, once I checked them in. Oh horror! The build ritual failed! And how did they 'fix' it? No, not by looking at the tests and sorting out where the tests might be too strict or where they might be pointing out some issues. They simply commented out all the code in the tests and checked them in again.
Now the build ritual does not fail anymore and the unit test ritual also has been sucessfully completed. Bravo! Now you can go back to sleep and hold up your build reports with 100% sucessful unit tests when somebody asks.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
CDP1802 wrote: they were not able to come up with any specifications at all.
Looks quite familiar to me. Someone in our company decided then that we desperately need to get a test tool...
|
|
|
|
|
Keep the managers busy, distract them, so they leave you alone.. lol
I just test, as a user would. I'm a programmer & designer & db admin & test tool.
*throws a bone to manager to keep him busy with something else* FETCH!
|
|
|
|
|
CDP1802 wrote: Now the build ritual does not fail anymore and the unit test ritual also has been sucessfully completed. Bravo! Now you can go back to sleep and hold up your build reports with 100% sucessful unit tests when somebody asks.
Wouldn't that be NaN% successful? Or did they only comment out the code INSIDE the tests, not the tests themselves?
|
|
|
|