Answer the question
In order to leave comments, you need to log in
How to properly split a class?
Guys, there is a class for working with goods. Methods for getting data of the select type take about 10KB of code. But there are methods for creating and editing goods. And here they weigh about 20KB. That is, I have a large class of 1200 lines of code for working with goods. I'm used to dividing into parts, because it's wrong to keep everything in one file.
Can I create a ProductModify descendant class and make three methods creade, update, delete into it? Or are there easier ways?
Answer the question
In order to leave comments, you need to log in
Do you have html inside too?
And in general, the whole logic of the site?
It is necessary not to divide the goods, but the logic into separate parts, in the same place, obviously, more than one model is used, so it should be taken out into different models and all that.
Well, apparently ORM to take, and not to write pure SQL in tons.
Partial Class - A class that can be split into files
www.tutorialsteacher.com/csharp/csharp-partial-class
By using partial keyword we can divide the class in c# . To know more about partial keyword check below articles.
https://www.tutlane.com/tutorial/csharp/csharp-par...
https://www.tutlane.com/tutorial/csharp/csharp-par...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question