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, 2022 in C# by pranav
• 2,590 points
583 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, 2022 by krishna
• 2,820 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, 2022 in C# by jyoti
• 1,240 points
441 views
0 votes
0 answers

How Convert VB Project to C#

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

Jun 11, 2022 in C# by jyoti
• 1,240 points
741 views
0 votes
0 answers

How to force overriding a method in a descendant, without having an abstract base class

This is my code using System; using System.Collections.Generic; using System.Linq; using ...READ MORE

Jun 11, 2022 in C# by krishna
• 2,820 points
1,013 views
0 votes
0 answers

How to add a gridview to a C# winforms project with a list of objects as the datasource

In Visual Studio 2015 community, I'm creating ...READ MORE

Jun 11, 2022 in C# by krishna
• 2,820 points
1,201 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, 2022 in C# by rajiv
• 1,620 points
1,843 views
0 votes
1 answer

Solid Principle examples

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

answered Jun 14, 2022 in C# by jyoti
• 1,240 points
763 views
–1 vote
1 answer

Examples of GoF design patterns in .net

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

answered Jun 23, 2022 in C# by krishna
• 2,820 points
589 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,140 points
5,764 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, 2022 in C# by krishna
• 2,820 points
573 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, 2022 in C# by krishna
• 2,820 points
739 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP