How to implement SOLID principles into an existing project

0 votes
Sorry for the subjective nature of this topic, but I'm stuck, and I'd appreciate any assistance and advise from anyone who's faced this problem before:

I'm working on a large RESTful API project in C# 2.0, and some of my classes have grown to be enormous. With several dozen members and functions, my main API class is an example of this (probably approaching hundreds). As you might imagine, not only is maintaining this code becoming a pain, but simply navigating the code has become a chore.

I'm fairly new to SOLID principles, however I'm a huge lover of design patterns (but I am still at that stage where I can implement them, but not quite enough to know when to use them - in situations where its not so obvious).

I need to reduce the number of my classes, but I'm not sure how to go about doing so. Any ideas guys?
Jun 11 in C# by pranav
• 2,320 points
10 views

1 answer to this question.

0 votes
It will be a lengthy procedure. You must read the code and refactor any areas that do not adhere to the SOLID principles into new classes. The refactoring process can be aided by using a Visual Studio add-in like Resharper (http://www.jetbrains.com).

In an ideal world, you'll have a large number of automated unit tests to ensure that your changes don't break the code.

Additional Information

You must discover methods that are related to one another in the primary API class and develop a class that more explicitly defines the operations that the method does.

Ex.

Assume I have an Address class with different variables for street number, name, and so on. This class is in charge of inserting, updating, and deleting data. I could create a method named GetFormattedPostalAddress() that returned the formatted address if I also required to format an address in a specific way for a postal address.

Alternatively, I might rework this method into a class named AddressFormatter, which takes an Address as a function Object() { [native code] } parameter and returns the formatted address via a Get property called PostalAddress.

The goal is to divide various responsibilities into distinct classes.
answered Jun 14 by krishna
• 1,340 points

Related Questions In C#

0 votes
1 answer

How to enumerate an enum

foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit))) { } Note that ...READ MORE

answered Jun 14 in C# by jyoti
• 1,240 points
9 views
0 votes
0 answers

How Convert VB Project to C#

I have a VB project that has ...READ MORE

Jun 11 in C# by jyoti
• 1,240 points
8 views
0 votes
1 answer

How to iterate over a dictionary?

I have seen this being used. In ...READ MORE

answered Jun 7 in C# by pranav
• 2,320 points
14 views
0 votes
1 answer

How to initialize a list of strings (List<string>) with many string values

Simply remove the () at the end. List<string> ...READ MORE

answered Jun 13 in C# by krishna
• 1,340 points
10 views
0 votes
1 answer

Which design pattern to use for pre-process process and post-process task

You have pre-defined and precise steps to ...READ MORE

answered Jun 9 in C# by rajiv
• 1,620 points
11 views
0 votes
1 answer

Solid Principle examples

I am not a specialist like others, ...READ MORE

answered Jun 14 in C# by jyoti
• 1,240 points
12 views
0 votes
1 answer

Examples of GoF design patterns in .net

I am attaching some links. Go through ...READ MORE

answered 5 days ago in C# by krishna
• 1,340 points
6 views
0 votes
3 answers

Trying to upload files using Selenium(C#)

You can try using Javascript Executor to ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,100 points
4,468 views
0 votes
1 answer

How to convert JSON text into objects using C#

To make a class out of a ...READ MORE

answered Jun 13 in C# by krishna
• 1,340 points
11 views
0 votes
1 answer

How do I turn a C# object into a JSON string in .NET

Newtonsoft.json can be used to accomplish this. ...READ MORE

answered Jun 13 in C# by krishna
• 1,340 points
9 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP