11 Replies - 894 Views - Last Post: 19 December 2016 - 11:57 AM

#1 fearfulsc2  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 169
  • Joined: 25-May 16

How to tackle already-made code?

Posted 16 December 2016 - 09:17 AM

Hey everyone, I have always coded and programmed things from the beginning and learned how to program that way by being given a set of requirements and the desired date of completion.

Just recently, I was assigned to a project to look at and maintain/configure/update code of an application that they are using. I was given the credentials to get the code from the repository and so forth.

The code has not been touched in 3-4 years, so I'm sure that they will have a lot of security vulnerabilities as a lot of things have changed in the last 3-4 years in the cyber security world.

This one application has over 20,000+ lines of code in C# and is also using Web Forms instead of MVC or angular.

So my question is, where do I start when looking at this code? I don't have a virtual environment setup for me, so I'm not even allowed to test the application yet. So what are some best practices when taking over someone else's code?

Is This A Good Question/Topic? 0
  • +

Replies To: How to tackle already-made code?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13554
  • View blog
  • Posts: 54,090
  • Joined: 12-June 08

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:20 AM

Get it to compile first.
From there get an eyeball for the flow of pages.. see what controls are being used.. etc.
Then look at the code behind. Throw some break points around and off you go.
Was This Post Helpful? 0
  • +
  • -

#3 fearfulsc2  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 169
  • Joined: 25-May 16

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:22 AM

I do not have a virtual environment set-up for me yet as they are trying to allocate the resources for me so that I can actually build and run the application. So right now, I'm in the repository looking at the code from there.

But as a note, I should see how the flow of the application goes from the starting page to how everything else interacts?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13554
  • View blog
  • Posts: 54,090
  • Joined: 12-June 08

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:28 AM

Yeah.. Webforms operates like most any other webpage.. display/actions.. some pages are linked some are not.. etc.
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2342
  • View blog
  • Posts: 9,393
  • Joined: 03-December 12

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:30 AM

The very first thing to do, and you may have to wait until you can get a working application, is to figure out the structure. You can know you need to change line 500 of this file, if you don't know where that file is it's a hindrance. Hopefully, the structure is sound, though that is normally not the case. Just knowing where things are and how they are implemented are quite important when maintaining a system.
Was This Post Helpful? 1
  • +
  • -

#6 fearfulsc2  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 169
  • Joined: 25-May 16

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:39 AM

So far, all I know is that it's very server-oriented, so I think I should be using MVC instead of Angular for this one particular application. I guess I could keep it with WebForms since it's already there and implemented, but I also have to look at the other projects within that application since the UI part is only one part of the application.
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6507
  • View blog
  • Posts: 14,377
  • Joined: 02-June 10

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:41 AM

When it comes to legacy applications/legacy code my first rule is:
If it ain't broke don't fix it.

Sure we like to get in there and muck about and modernize... But is there a real need, or just a desire?

With applications that old its usually a better plan to architect a replacement application from scratch. Something modern and up-to-date. Then confirm it is genuinely working. Then replace the use of the old applicaiton with the new. That way you don't break functionality in live production code that has a purpose in life and probably earning income.

Concentrate on the 'maintain' part of that job description, for the legacy code. Suggest 'update' would take just as many man-hours and still result in a mess; where 're-create' from new utilizing existing logic and importing code that doesn't need changes results in a better product for modern platforms in the same amount of time.
Was This Post Helpful? 1
  • +
  • -

#8 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2342
  • View blog
  • Posts: 9,393
  • Joined: 03-December 12

Re: How to tackle already-made code?

Posted 16 December 2016 - 09:53 AM

Apparently I didn't get what you originally stated? When you maintain existimg code, you don't change stucture, such as switching to a new way of doimg the same thing, You fix, patch, and update. Don't get it in your head that they should be doing it this way or that, you clean what they have, the end. Rebuilds are where you weigh in with modernizing and changing how it all works, otherwise you will drive yourself nuts when the time constraints say there is no way to do what you want to implement.
Was This Post Helpful? 1
  • +
  • -

#9 fearfulsc2  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 169
  • Joined: 25-May 16

Re: How to tackle already-made code?

Posted 16 December 2016 - 10:46 AM

That makes a lot of sense.

The things that matter the most to them is that the application is as secure as it can be from vulnerabilities and exploits. So in this case, would updating the packages used be a good start? And then I'm assuming that there will be compatibility issues with the updated packages since things change such as references and sometimes inheritance of classes since I have had a similar issue in the past with one of my past projects.
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5922
  • View blog
  • Posts: 20,247
  • Joined: 05-May 12

Re: How to tackle already-made code?

Posted 16 December 2016 - 02:47 PM

Take time to read about branch by abstraction. If you absolutely much change some code, this will come in very useful.
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5922
  • View blog
  • Posts: 20,247
  • Joined: 05-May 12

Re: How to tackle already-made code?

Posted 16 December 2016 - 02:55 PM

Sometimes, the facilities provided by Visual Studio to navigate code is not sufficient. Do not be afraid to also open the code using a different source code editor like Source Insight or CodeWright. I've successfully used both editors to figure out the structures and call graphs of thousands of lines of complex code. These editors seem to have a more natural interface to "dive down a call graph or inheritance tree" and pop back up again. Make exploration so much easier.

Also, in your off time, browse through Beautiful Code. As I recall, there are some good tidbits there about how to "grok" other people's code.

As an aside, I must be on roll today: This is my fourth reference to "Beautiful Code" and/or some articles that are published within it. Two are here in DIC.
Was This Post Helpful? 0
  • +
  • -

#12 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: How to tackle already-made code?

Posted 19 December 2016 - 11:57 AM

Quote

So far, all I know is that it's very server-oriented, so I think I should be using MVC instead of Angular for this one particular application


That doesn't make sense. Angular is a frontend library, ASP.NET MVC is a back-end. They're not mutually exclusive; there's no good reason you can't use both.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1