Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,
I feel a little bit desperate today, so I seek for guidance or another way to relief the pain.
It's all about a project I was recently assigned to. It mainly consists of three DotNetNuke modules (that's not the problem). Those modules have been written by students in their early time.

I already posted a little bit of it here: http://www.codeproject.com/Feature/WeirdAndWonderful.aspx?msg=4473067#xx4473067xx[^]

I am trying for days to figure out what's going on within those modules. The more I read the more I get the feeling that some lack of understanding for OOP made them spread code like mad without any relation. Tons of classes, redirects, self-made session-managers (inherited in three levels with only a const string for the key to change). Only auto generated comments (or comments in a language I do not speak).

It feels like going through an infinite tree view that explodes right in my face whenever I try to figure out what is going on. After 10 minutes I am completely lost, and the lack of structure makes me fail to write down diagrams or whatever to ease understanding.

Especially the SQL part is a Halloween version of a drunk mad man.
Like shown in the above mentioned link it's nearly not possible to understand the SQL that is fired without the debugger filling in the constants... Yeah, the debugger...

The search for example. It triggers the same page that is used to fill out the search-form, writes search-parameters to a Session-Object, redirects and then does some magic.
The pages are created using several objects to write out HTML and JavaScript.
I found over 15 classes that create the Google-Map with the markers... of course for the obsolete API. It basically passes around a StringBuilder to add lines which makes it nearly impossible to see where the closing brackets are and how they match...

Have I mentioned the use of custom tokens for creating the HTML? Over 50 of them and templates stored wherever to parse out the HTML? All use a XML reader that is passed around for reading the values...

I was always a big fan of OOP and I consider myself quite reliable when using it, especially regarding structure and encapsulation of specific problems. But this stuff drives me insane...

Does anybody have a hint for me or knows about a way to make this one a little bit easier?
Normally I try to tackle such things in a "Yeah, something interesting... let's do it!" way, but this time I can hardly contain myself...

If you have any comments or ideas, I'll be happy to hear about them ;)

have a great day
Andy



Update
Some days passed by since we made the decision to put everything on the table and sort it out. Luckily it wasn't too bad at all and we all finally agreed that it would be a good idea to trash the current project and redo it completely. A great opportunity if you wan't to hear my opinion, because it gives us a chance to level the project up to today's' standards. It will still be a DotNetNuke project, but just for displaying the results or entering search parameters.
The obsolete GoogleMaps API part will be replaced too, and we will sacrifice the SQL constant mess to the code-devil, so I can see a silver line at the horizon ;)

take care people and thanks to all those who participated in this journey ;)
Cheers
Andy
Posted
Updated 12-Nov-13 4:04am
v2
Comments
OriginalGriff 7-Nov-13 9:35am    
Start at the top:
Find the person who hired the students, and kick the **** outta him.
Then, you can start hunting down the students...

It may not fix the code, but it'll probably make you feel better!
Sergey Alexandrovich Kryukov 7-Nov-13 9:36am    
Great idea... :-)
—SA
hoernchenmeister 7-Nov-13 10:01am    
That would work surprisingly fine... a nice sideffect would be that it would clear the "redesign" problem ;)
On the other hand, the plan for the project was quite nice as far as I know, just nobody watched over the result... and it's quality :(
Sergey Alexandrovich Kryukov 7-Nov-13 9:36am    
I feel your pain. So often, using existing code is much worse then writing it all from scratch by yourself. Supporting bad code can be utterly counter-productive. Could you make it an option?
If someone demands you to solve the problem without replacing existing code, it may or may not be contradictory. Actually, it's hard to judge, is the problem in your skills or the code is bad and does not worth supporting. There are so many ways to do a bad job and create a complete mess.
—SA
hoernchenmeister 7-Nov-13 9:54am    
Thanks Sergey, good to not be alone out there ;)
I really guess the biggest problem was that those guys (who program pretty fine right now but won't support the project - guess why) were just at the beginning of their careers. Maybe they thought it would be a good way to make some classes, then ran into trouble and over the time just added bunches of code just to make the thing work somehow. They inherited from things that really didn't need that, lost the overview and where pretty happy when they finished their studies and moved on to different jobs. They honestly have been kind people after all, but now they are out of reach...
I already mentioned the "redesign" question, but my superior wasn't too happy about it. Money was spent and I guess throwing it away would be something "evil" because of that. The project itself isn't too complicated, websearch, results, Gogole-Maps, tourism stuff... but a certain fear is around that it might become complex after the 90% is done (have you heard about this: 90% costs 10% of the total value while the last 10% cost 90% of the budget... not wrong, but it really doesn't help in the end).
I can't really say if it would be sufficient to just exchange parts of it, I am still unable to get the complete picture, so I have a hard time estimating how long a redesign would take.

After all especially the time that would be necessary to just make changes to the SQL (besides identifying the statement), imagine you need another column... should I define a new constant and put another {x} into the String.Format call... You have no idea how dirty I feel just thinking about it ;)

Thanks for your comment Sergey, it is kindly appreciated.

cheers
Andy

1 solution

hoernchenmeister wrote:
I already mentioned the "redesign" question, but my superior wasn't too happy about it. Money was spent and I guess throwing it away would be something "evil" because of that.
Maybe your "superior" does not understand how to be responsible for money. "Money spent" is not a valid argument. I hope you understand it yourself. Say, one has two options:
  1. Throw out the rotten code, this way admitting that money was spent for nothing; admit they are lost.
  2. Pretend that money was reasonably spent (perhaps to protect "authority" of the one who made the decision), enforce using it, and, as the result of it, waste a lot more money, for your and other's salary, for costs involving undelivered product, for delivering not working solution and dealing with the consequences.

And now think, who is really wasting money?

Here is what you should realize:

First of all, one of the most important qualities of an engineer is understanding such thing as anti-pattern, ability to identify and prevent or overcome them. At this moment, we can talk about the class of anti-patterns called "organizational":
http://en.wikipedia.org/wiki/Anti-pattern#Organizational[^].

Which one? This is a question. It could be just incompetence, and you need to test this person for being technically qualified for making the decisions like the one in question (yes, you need to, you). Alternatively (or in combination with the above), it could be this anti-pattern, closely related to the issue of "money spent": moral hazard: "Insulating a decision-maker from the consequences of his or her decision":
http://en.wikipedia.org/wiki/Moral_hazard[^].

Now, what can you do? There can be options. You should think thoroughly and not jump to conclusion right away. You need to test this person for ability to listen to people and to make quality decision (yes, you need to, you, nobody else). If you clearly and hopelessly identify one of the anti-pattens, those discussed above or close in their hopelessness, and you are quite positive that you cannot expect something better, and if you consider yourself a decent worker with dignity, you will need to make a last step and… get rid of this person.

How? 1) You can wait and see what tends to go on; the world if far from perfect, but ultimately right things happen; this person may appear unsuccessful and leave the company; it really happens in real life. 2) Leave this team or this company yourself. It might be a difficult decision, but the alternative is quite interesting: consider if you are ready to waste years of you life on trash and only lower your skills and reputation, or you would prefer to grow and move forward.

Last note: if you make a decision to wait and work in a nightmare working or moral conditions, do it consciously. How? Try to use this time working for yourself, not just for company. First of all, try to use this time for learning something really useful. For example, learn how not to write similar code.

[EDIT]

Please also pay attention for out discussion with Ron, in the below comments. His advice is very good, this is another real option. You can choose to rewrite the code anyway, and to do this underground. I tried to explain why it can be a good decision.

—SA
 
Share this answer
 
v13
Comments
Ron Beyer 7-Nov-13 16:54pm    
+5, I can't tell you how many times I've highlighted a project and hit the delete key because something was fundamentally wrong, and the time spent re-writing was much less than the time spent shoe-horning. I bet the OP has spent more time trying to understand the code than would be needed to start from scratch.

Personally I'd ignore the supervisor and re-write it anyway (between other assigned tasks), then roll it out when finished and say "look, I've already got something better".
Sergey Alexandrovich Kryukov 7-Nov-13 17:26pm    
Thank you Ron. I was sure you would understand it. And your advice is very good.

I got this experience many years ago. As I say, one of difficult parts of our work it tell "no". In many cases, the agreement between team members is far from perfect. This is not enough of excuse for doing nothing or sabotaging the works. In many cases, the really working solution is doing certain work underground. What's wrong with that? The organizational situation could be so nasty that you either do that work underground, or else, later, you could be blamed for not doing it... :-)

—SA
hoernchenmeister 8-Nov-13 3:10am    
Thank you Ron for sharing your thoughts.
Stealth-Redesign sounds like being a good idea if applicable. Unfortunately this will not be an option in this case because it will not go unnoticed :)
I totally agree that this should be handled this way if it's possible, especially if, as you mentioned, takes less time to recode than to understand it and then add additional bunches of code that lead to even more confusion later...
In this case we can all learn something new. I learned that I have to take my responsibilities seriously, and my superior might learn that hiring people from countries far away that just started to study IT and have not too much experience need proper supervision... and a good project plan so that adding bunches of code to introduce functionality that was left out when creating the project-plan might be reduced...
It is still a good advice though, thanks a lot for sharing it Ron!

Cheers
Andy
hoernchenmeister 8-Nov-13 3:00am    
Thank you Sergey for sharing your thoughts and experience. Your advises worked out fine for me already in the past and I am hopeful it will do this time ;)
I already spent three days in just debugging through this project, trying to get things together in order to get the big picture. But I have to admit that I can only fail in continuing to do so. My superior is normally a fine person who has his own opinions about how projects should be done, but in general he listens to my advises and accepts most of the ideas I come up with. In this case there is another anti-pattern involved that was missing in the list. I have no name for it but I'd call it "Junior/Senior Boss Father/Son" pattern... It is no excuse for the current state, but it introduces additional, family related misunderstandings that, especially in smaller companies, might add another layer of complexity.
My personal leave is already scheduled for beginning of next year, but that was so far unrelated to this project, I just want to see more, expand my knowledge and I am really looking forward to work in bigger teams again as I did in the past.
So what's left for me... I totally agree that it's my responsibility to ensure a certain level of professionalism when it comes to coding projects and in this case a rewrite will be the only good choice to make. Regarding money and regarding the quality of the project. There was certainly enough money spent on this beast and it's time to accept that this was a failure.
I have chosen to not continue to live this nightmare (besides this I want to mention that this is the only real project messed up this much, we have made several others that have been really interesting, challenging which teached me quite a bit, so all in all I have a good time). A well structured redesign will also improve speed regarding future changes (which will definitely occur). Unfortunately the "stealth-redesign" isn't an option. While it sounds fine I always preferred convincing people about something and in this case there is no other option. I just can't make changes, my IT colleague also agrees with me (he can't understand it either) so we will put our arguments on the table today. I don't fear the ugly discussion that might come up, but there is also a good chance that my suggestion will be accepted... after all we just try to do what's best for the company, not to mention the next guy who will have to deal with this project.
This might be one of those moments I just have to go through and in a few weeks when we all look back we will ahve a laugh and a few beers (payed by the money that we saved).
Your solution really gave me a boost and some new arguments that I will use in the upcoming discussion. I am optimistic that it will work out, and there can't be only sunny days, right? Sometimes you just have to run through the rain and make the best out of it (rain can be nice too if you try to find something you like instead of arguing with what you don't like).
Additionally your answer made me feel convenient again, it's nice to share opinions and experiences with people who can understand and take the time to think about it in order to help out a fellow coder :)
I love what I do for a living, I always did and I am quite sure I will come out of this bigger and stronger tha before. Even if this project sounds really bad, it still teaches me something new... in this case realizing that I am not just a tool but someone with a mission to be accomplished... Making the right decision that is the best for the company I work for. Now I will gear up, get my stuff together and do what I am here to do...
Thanks again Sergey, your advice is kindly appreciated
I keep you updated ;)

Cheers
Andy
Sergey Alexandrovich Kryukov 12-Nov-13 10:27am    
...It's just to wish you the best of luck and to tell you: your comment sounds interesting to me. It makes you me think that you probably are quite capable of making really well weighted mature decisions.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900