I am starting on a project, together with other developers. The customer is a community and wants to have a website where people can apply for a service. According to their family status, the persons are being distinguished into cases, i.e. married, divorced, living together with a partner, widow. For every case there exist some different questions, although most of them are common (like bitrhday place, father name and so on). The technology used is ASP.NET Core MVC. The one proposition is to make a model, a controller and a view for every family status. The name of the classes should accordingly change, like MarriedModel.cs, MarriedController.cs, or DivorcedModel.cs, DivorcedController.cs etc. My approach is a more OOP one. Since we have an entity of a Person, this is our model class. Family status, liked married, divorced etc, consists an attribute. The actions should change dynamically passing the attribute parameter into the controller which would control the view appropriate. I find that this way we avoid redundancy and code copying, which is very bad enginnering. Moreover we have less code in the end. Others say that with the first way we would gain on flexibility in case something changes during developement. What do you think?
nstk
Posts
-
Initial design question on an ASP.NET Core MVC project. -
How to avoid backend stored proceduresIn the team I am currently working with, we have to deal with a software which was initially thought as a database driven programme. As a result of that, there is a set of Databases, having each more or less 300 stored procedures! We cannot anymore accept writing backend stored procedures, as they do not contain any object oriented thinking and in the end we have a procedural code like in the days of old good C. We have to deal with lots of bugs, which is not sure whether they come from backend (MSSQL) or the frontend (Windows App in C#) Are there any other solutions to avoid so much SPs and still have a professional code? I thought of exchanging SELECT SPs through Views but I am interested on what other ways do exist. Thank you.
-
Which is better architecture, also for security reasonsHallo, im a writing a quite bigger than usually project, and I am dealing with some questions considering architecture and security. To make it short, I have a Windows server with a WCF installed, which is waiting for an outside question from a client that needs some updates. The updates have to be created from a dll, which accesses a Database, runs sql scripts and provides a zip file in the end. Is it ok to call the dll from a function inside the WCF? That function should then pass a string which needs the library. Would it be better to call a programm that consequently calls the dll, thus having a separated instance between WCF Service and the library, which accesses the database? Or maybe there is a better solution? Thanks in advance.
-
Passing an object through different window classes in Windows FormsHello and thanks for your help. Of course it works that way, but assuming I have 10 different objects in the Main Form and I need their data in several other Forms of my programme, let's say 6 new forms, do I have to create similar objects of all those 10 in everyone of the 6 Forms? Isn't there a way to make an object available in the whole programme?
-
Passing an object through different window classes in Windows FormsOK, I found this http://msdn.microsoft.com/en-us/library/532wtsbc(v=vs.90).aspx and corrected accordingly. Thanks again.
-
Passing an object through different window classes in Windows FormsThanks for your help. Unfortunately I am getting an error, and I think I have seen it before when I was trying to solve that problem, maybe because I have a class Students on a file students.cs The error is: Inconsistent accessibility: property type 'Studentstest.Students' is less accessible than property 'Studentstest.Data.Students' Where Studentstest is the name of the project containing the following classes: Form1.cs, Data.cs and Students.cs
-
Passing an object through different window classes in Windows FormsI have a main Form public partial class Form1 : Form a Data Form public partial class Data : Form and a class Students in another file with public string Name { get; set; } Now on Form1 I create Students stud = new Students(); and then I give stud.Name = "hisname"; Then by clicking a button on Form 1 the following happens Data datawindow = new Data(); datawindow.ShowDialog(); When Data Form loads I want to get in a text box txtName.Text = stud.Name; But the object stud is not available on Data form.
-
Passing an object through different window classes in Windows FormsIn a Windows Forms application, I have a class Students and then I create a new object student inside the class Form1 which represents the main window of my application. So far so good, but I need a second window which will show the user some of the student's data. Therefore I create a second class derived from Form, let's say StudentsData : Form and then I let a new object of that class be created inside the Form1 class, and again through ShowDialog() I let that new Window be visible. What I do not succeed is to pass the student's data into that window. I think the real question should be, how do I make an object persist through different other classes/objects? Any help would be appreciated.
-
Is this an OOP Programme?That exactly is my point.
-
Is this an OOP Programme?Thanks for your replies. I am aware that C# an OOP language is. I am also aware that it is not obligatory to have inheritance or interfaces. But in this case everything is against an OOP design. And if every function in a programme can change every variable in it, then imho it has nothing to do with OOP, although in it's syntax there are always classes, since otherwise it wouldn't compile. I wrote this message because I wanted to get a feedback from the forum, since I plan to write to my boss that this piece of code is worthless and should be rewritten with a new concept. As a matter of fact, we are being confronted with all these problems that are described in the software enginnering literature since years. We always deal with a lot of bugs and problems, no one is completely sure of what is happening, we have not a complete picture of the structure, we are steadily debugging step by step hoping to find out what changed that variable at the last moment(because any class can do that) and even the person who did program it and recently made some changes, had to search for some unexpected new errors that arose. I think it's time to get rid of that piece of software for the simple reason that it is not as OOP designed. Any objections?
-
Is this an OOP Programme?Hello, I recently began working on a project in C# .Net, written in MS Visual Studio 2010, where many things are at least peculiar... All files are in root directory, meaning there are no subdirs. Files include several classes which, in best case, may belong to the same or a similar fact. Even if there is only one Class in a .cs file, it doesn’t always have the same name, meanig for a Class Car the file may have a name Frm_View.cs, in other words completely irrelevant to the class name. Hungarian notation is being used, like in the old MS times. There is an enorm amount of internal, static and both internal static variables and functions. There is no inheritance between classes. There are no interfaces. It seems to me that it is about an old C programm, which has been ported into C#, but only as far as syntax concerns. What do you think?
-
Entity Framework and ClassesAs I understand it, in Entity Framework we create the backend from which the classes for our frontend code derive. Does this mean that we don't need any thoughts about classes building anymore? Doesn't this make at least a part of OOP thinking and of UML useless? Thanks.
-
Could there be a base class for customers, employees and suppliers?Shouldn't Person inherit from Contact? The arrow direction between them indicates the opposite situation.
-
Could there be a base class for customers, employees and suppliers?Nagy Vilmos wrote:
A customer is a person or a company, A company also has a person as a contact.
What about putting the Persons class as a nested class in the Company class in that case? Complicated?
-
Could there be a base class for customers, employees and suppliers?Thanks for your effort, I really appreciate this great help. I will indeed develop this as an exercise and if there is something to discuss I will write it here. :)
-
Could there be a base class for customers, employees and suppliers?Richard MacCutchan wrote:
Sorry but you are asking for a tutorial on OOP
Well, not really. I 've read already many books about OOP, even studied and done some programmes. I found out that there can be solutions and concepts which vary a lot. In the above example there could be two solutions with or without inheritance between the classes I mentioned. And both could be acceptable and good. Both? Maybe? THat's why I asked here, to get answers from more experienced members. This cannot be done in a tutorial. Thanks for the links.
-
Could there be a base class for customers, employees and suppliers?I understand what you are saying but there is no real project. What I am really trying to do, is to find out why and where to use a base class in a hypothetical (but indeed very common) design problematic of, let's say, an ERP software. If we narrow the problem to customers and employees, and assuming that customers are only individuals, it is obvious that both are persons, therefore a base class Persons and two inherited classes of Customers and Employees seems to be very reasonable. But do we need to build a base class in our programme and if yes why? What is the real practical purpose of doing so? In my opinion this generalization of our two "real" classes seems to complicate designing without any having any profit from it. That is my real question to the forum (although some of the answers above have already answered that too).
-
Could there be a base class for customers, employees and suppliers?Nagy Vilmos wrote:
From experience, there should be a
Person
that is used to represent a physical being [and maybe a role in some cases] and anOrganisation
to represent companies [which will havePerson
contacts.Do you mean in a form of nested classes?
-
Could there be a base class for customers, employees and suppliers?Thanks for your answers. I was reading Entity Framework and this is how the question arose: in the database we usually have a table customers and a table employees. Using EF we would get two separate classes for those groups and I was wondering how to deal with inheritance. It seems to me that by using EF we coulnd't use inheritance at all. But this maybe another story...
-
Could there be a base class for customers, employees and suppliers?In a software for a company, we usually have customers, employees and suppliers in what regards humans. Therefore a reasonable (meaning a good one) OOP approach would be to have a class 'Persons' with attributes such as name, surname, address etc. and then let the classes 'Customers', 'Employees' and 'Suppliers' derive from the class 'Persons'. But, on a second thought there is a problem. How do we deal with customers and suppliers which are companies?