|
Indeed, not enough Objects...
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
These instances of code changes were not done by a programmer. A developer maybe, but not a programmer.
|
|
|
|
|
Perhaps we could debate a bit on the difference between programmer and developer?
Anyway, whoever made those changes had no clue what they were doing so it seems
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
I certainly agree that the coder was inept.
On the subject of developer vs programmer. Even though my title is,"Sr Developer Architect" I consider myself a programmer. I'm as comfortable using VI and make as I am Eclipse or Visual Studio. Therein lies the difference to me. I feel the word developer connotes one who requires the modern IDE with all it's pop-up hints, which 95% of the time just get in my way.
Then there is VI where one never has to take their hands of the keyboard to do virtually everything possible when it comes to the programming process.
I live in both worlds in my efforts.
Now all of that is entirely subjective observation so it's really not debatable. But I would be interested in your thoughts.
I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
|
|
|
|
|
MarvinMartian wrote: I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian Ehhh... What's up doc?
I always felt a programmer to be more like someone who writes code that he is told to write while a developer thinks of how the code should be written and can write it too (somewhere between a programmer and an architect maybe?). I think my contract says I'm a software developer just like all my colleagues, but when it comes to coding new libraries and thinking about architecture I am a lot better than my colleagues who couldn't name a single Design Pattern or SOLID principle. And when it comes to that you are, judging from your title, far more skilled and knowledged than me even though you consider yourself a programmer.
I think everyone who writes code should have a basic, but solid understanding of architecture no matter their title. I think programmers and developers work at a small part of software while architects overlook the entire project. But then again, I work at a small company that doesn't have architects
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
It's interesting that we have the exact opposite view of what it is we think we are. LOL
It may be that when I started, there were no developers, only programmers. While in high school in the late 60's I wrote my first FORTRAN programs. They did nothing but they did spark an interest.
I became a mechanical engineer, primarily for the $$, however I continued programming my stress analysis in FORTRAN and gradually began to like that more than building amazing things out of steel etc.
I now occasionally do electronic design, embedded coding, real time data collection from operating room instrumentation all while "architecting" financial solutions using SOA at a large life insurance company.
I'm not boasting by any means. There is much I don't know. That's why I'm about to take a crash (8 week) course "Advanced Java Programming". Just so I can put it on my resume. (And take the official certification. You gotta know all the buzz words and acronyms.) In fact I learn something from every project I work on.
I'm currently discovering Android development having just installed everything I need. No iOS for me, I've seen "objective C", it ain't C! Also there is that $100 here and there and you can only develop on a Mac. (You can run iOS in VMWare but it crashes if the app you're running wants to identify the Mac you're running on!)
I am also proud of the fact that at age 63 I still have the urge to do this and learn more. Now that is the boast! LOL
I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
|
|
|
|
|
|
Can see this happening in Python:
if code.length in [0,1,2,3,4,6,7]:
....
Don't forget to rate my post if it helped!
"He has no enemies, but is intensely disliked by his friends."
"His mother should have thrown him away, and kept the stork."
"There's nothing wrong with you that reincarnation won't cure."
"He loves nature, in spite of what it did to him."
|
|
|
|
|
Naerling wrote: Throw New Exception("Code should be 5 characters long.")
Well, shouldn't error change accordingly?
Throw New Exception("Code should be 5 characters long or should exactly not be 6 characters or oh wait, not exactly 7 characters too, anything other than that.")
-
Just that something can be done, doesn't mean it should be done. Respect developers and their efforts!
Jk
|
|
|
|
|
Hi all,
I think the following could also qualify as a coding horror but I intentionally wrote it this way (one giant linq statement) because of a discussion with a collegue:
Directory.EnumerateFiles(args[0], "*.cs", SearchOption.AllDirectories).AsParallel().Select(f => new { File = f, Bytes = File.ReadAllBytes(f) }).Select(f => new { File = f.File, Bytes = f.Bytes, Encoding = f.Bytes.Take(3).SequenceEqual(new byte[] { 239, 187, 191 }) ? Encoding.UTF8 : Encoding.Default }).ForAll(f => File.WriteAllText(f.File, f.Encoding.GetString(f.Bytes).Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Select(l => new { Line = l, Index = l.Select((c, i) => new { Char = c, Index = i }).FirstOrDefault(c => c.Char != ' ' && c.Char != '\t') }).Select(l => l.Index == null ? l.Line : l.Line.Select((c, i) => (i < l.Index.Index && c == '\t') ? " " : c.ToString()).Aggregate((s1, s2) => s1 + s2)).Aggregate((s1, s2) => s1 + Environment.NewLine + s2), f.Encoding));
Here another version where I tried to get a proper formatting:
static void Main(string[] args)
{
Directory.EnumerateFiles(args[0], "*.cs", SearchOption.AllDirectories).
AsParallel().
Select(f => new {
File = f,
Bytes = File.ReadAllBytes(f)
}).
Select(f => new {
File = f.File,
Bytes = f.Bytes,
Encoding = f.Bytes.Take(3).SequenceEqual(new byte[] { 239, 187, 191 })
? Encoding.UTF8 : Encoding.Default
}).
ForAll(f => File.WriteAllText(f.File,
f.Encoding.GetString(f.Bytes).Split(
new string[] { Environment.NewLine }, StringSplitOptions.None).
Select(l => new { Line = l, Index = l.
Select((c, i) => new { Char = c, Index = i }).
FirstOrDefault(c => c.Char != ' ' && c.Char != '\t') }).
Select(l => l.Index == null ? l.Line : l.Line.
Select((c, i) => (i < l.Index.Index && c == '\t')
? " " : c.ToString()).Aggregate((s1, s2) => s1 + s2)).
Aggregate((s1, s2) => s1 + Environment.NewLine + s2), f.Encoding));
}
So what does this do?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
args[0] should be a directory where C#-Files are located (*.cs). It opens all files, does a bit of Encoding-analysis (this might not work in every case but its fine for me), replaces Tabs at the beginning of each line with whitespaces (4 for each tab), removes alle whitespaces and tabs in otherwise totally empty lines and writes the file back with the proper encoding.
Interestingly this runs faster than I would have expected. For a codebase with about 8800 files it runs just a few seconds. I would even think (haven't measured it) that searching, reading and writing the files is more time consuming than the rest of the linq in between.
Robert
|
|
|
|
|
It's so bad, you can't even get it in the right forum...
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
|
|
|
|
|
|
I should probably clarify why and how this code was created:
We have a relatively large codebase. Some code files are old (C# 1.0 times) and contain tabs instead of white spaces (this was the default setting in VS2003 if I remember correctly). Now everytime we edit one of those files Visual Studio (now 2010) starts replacing the tabs automatically. This is simply annoying when using diffs and can be a complete pain when doing merges in our SVN. So we just had the idea to replace all left tabs with one big update.
While discussing on how to do it was just an amusing idea to make it with Linq. The code was executed exactly one time (ignoring test runs) and will never be touched again. Its nothing that will get checked in in production code or anything like that.
Robert
|
|
|
|
|
(This is kind of off topic but I don't understand why they changed to defaulting to putting spaces at the front. If there are tabs (one tab per indent), it's easy for each developer to set his tab size to what's comfortable for him, and everyone gets to see the code with the indentation they like. As soon as it's spaces everyone's forced to view it the same way.
I get around this by using a non-fixed-pitch IDE font (so spaces are narrow) but it just seems like a big step backwards. Tabs are there for exactly this purpose.
|
|
|
|
|
I think the problem is when the two are mixed in the same line. Then it does not seem to matter how you set them lines don't align.
I also worked on a VMS system where the default was to use tabs - but it had stops at every 8 columns and if you set yours differently it was a mess.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
BobJanova wrote: each developer to set his tab size
How? In Notepad or another text editor? In a terminus emulator? How about if I include a code snippet in a Word document? Or in a CP post?
TABs are evil and must be abolished.
|
|
|
|
|
Any decent text editor (including IDEs) will let you set the display size of tabs. So will Word. Most web browsers will display tabs in a <pre> as 4 spaces or thereabouts which is what most people use for indentation anyway.
|
|
|
|
|
BobJanova wrote: Any decent text editor
I must not have any of those.
Plus, the worse problem is files with mixed TABs and SPACEs.
|
|
|
|
|
Notepad++ is very good. Shows tabs, spaces, does column deletes and highlights matching brackets, braces, parens etc. Also has modes for different languages C#, C++, VB, Lisp etc.
And it's free.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
I agree most people don't use the View White Spaces option in edit and the readability of source code goes to hell when people are not maintaining a consistent spacing. There is also the benefit that using tabs also results in smaller files so there is less demand for storage for Source control history for files this way. In larger projects its noticeable.
nothing
|
|
|
|
|
Robert Rohde wrote: Its nothing that will get checked in in production code or anything like that.
Famous last words there...
Let's face it, after Monday and Tuesday, even the calendar says WTF!
Be careful which toes you step on today, they might be connected to the foot that kicks your butt tomorrow.
You can't scare me, I have children.
|
|
|
|
|
Robert Rohde wrote:
Directory.EnumerateFiles(args[0], "*.cs", SearchOption.AllDirectories).AsParallel().Select(f => new { File = f, Bytes = File.ReadAllBytes(f) }).Select(f => new { File = f.File, Bytes = f.Bytes, Encoding = f.Bytes.Take(3).SequenceEqual(new byte[] { 239, 187, 191 }) ? Encoding.UTF8 : Encoding.Default }).ForAll(f => File.WriteAllText(f.File, f.Encoding.GetString(f.Bytes).Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Select(l => new { Line = l, Index = l.Select((c, i) => new { Char = c, Index = i }).FirstOrDefault(c => c.Char != ' ' && c.Char != '\t') }).Select(l => l.Index == null ? l.Line : l.Line.Select((c, i) => (i < l.Index.Index && c == '\t') ? " " : c.ToString()).Aggregate((s1, s2) => s1 + s2)).Aggregate((s1, s2) => s1 + Environment.NewLine + s2), f.Encoding));
did you honestly check in code like that ? if so WHY!?!
|
|
|
|
|
From my other post[^]:
Quote: The code was executed exactly one time (ignoring test runs) and will never be touched again. Its nothing that will get checked in in production code or anything like that.
|
|
|
|
|
but why ever have it in that "minified" unreadable format?
|
|
|
|
|
I love the smell of long and 'unreadable' LINQ queries in the morning!
Actually I think the well formatted isn't THAT hard to read. I guess it depends on what you're used to.
Basically, a quick look at the (formatted) code tells me you enumerate through files, do this parallel, select some stuff, use this to make another selection, with this last selection you loop through all items in that collection and ok... It gets a bit fuzzy after that, but you end up selecting individual lines and even chars and putting them back together again.
That's probably more than I could tell from a quick look at any piece of 'normal' code.
The horror in such code lies not in readability (not using LINQ might stretch the code to twice or thrice its size and many 'normal' code is just as unreadable), the horror is in debugging these things! You can't make changes while running, you can't see the values of variables, you can't see the results of functions... It's a disaster!
That said, I wouldn't use it in production code, but as you mentioned, neither do you
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|