N
N
NDimo2015-10-24 01:37:55
Programming
NDimo, 2015-10-24 01:37:55

Proper software development!?

Hello!
For personal experience, I develop a certain program. The programming language is C#. And he first began to build the business logic of the program in a UML diagram. It turned out something like this (this diagram is not correct, that is, an approximate template that is subject to further corrections and additions. Approximately 1/3 of the program):
b0faa0c975774cda9bcc540f6f7d3561.jpg
After these sketches, I had a strange feeling?! Since I have no experience in developing and modeling projects, I asked myself such questions: "Am I doing everything right?", "Am I building a diagram correctly?", "Is it necessary to use class inheritance more or class aggregation?", "Normal Should I create a bunch of instances of other classes in each class?", "
I sketched several codes for this diagram. The creation and initialization of class instances turned out somehow like this. After what I saw, I became completely scared: D (also subject to further corrections):
55e2151a17de4017b363fd04b3b89510.png
As you can see, I have a lot of questions that I can’t get answers to. I ask experienced developers to criticize me, answer questions and give advice for the future! :D
Unfortunately, I did not find the spoiler tag.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
⚡ Kotobotov ⚡, 2015-10-24
@angrySCV

of course not correct. Where does this belief that everything can be done right come from?
you cannot create a new product right away, most of the things you can only understand in the process of implementation how to do better. Therefore, allow yourself to make mistakes, do not be afraid to make mistakes, make mistakes, correct yourself and develop the product.

Z
Zelimkhan Beltoev, 2015-10-24
@Beltoev

- Methods?
- No, I haven't heard
. To be more precise:

Company c = new Company();
c.SetInfo("Travel", "Touristic company");

Address address = new Address();
var idCountry = address.AddCountry("Name");
var idCity = address.AddCity(idCountry, "City");
address.AddOffice(idCity, "Main office", "Street", "Email", ... );

Contact contact = new Contact("website", address);
c.AddContact(contact);

Tour tour = new Tour("China", "Hong Hong");

c.AddTour(tour);
...

The sketch is rough, but the essence of how it would be more correct, I think, conveys intelligibly

V
VanKrock, 2015-10-24
@VanKrock

And here the nesting is also not needed.
Here you have the entity Company (Company) in your company, are there any countries? No, she has offices (Office)
And the offices already have a specific address (Address) and he doesn’t care about all the rest, so nesting is not needed here, it will be needed when filling out, for example, to show the dropbox to the user, for this, make the AddressDataBase what something with nested addresses. And usually if there are a lot of offices, then they indicate contact details
, that is

class Company
{
    public List<Office> Offices {get; set;}
    public string Description {get; set;} //Тут описание вашей компании: год основания там и все такое.
    public Contacts GlobalContacts {get;set;} //Глобальные контакты для всей компании
}

class Office
{
    public Address Address {get; set;}
    public List<Employee> Employees {get; set;}
    public List<Tour> Tours {get;set;}
    public Contacts Contacts {get;set;}
}

class Address
{
    public string Country {get;set;}
    public string City {get;set;}
    public string Street {get;set;}
    public string HouseNumber {get; set;}
}

class Tour
{
    public string Country {get; set;}
    public string City {get; set;}
    public Hotel Hotel {get; set;}
}


class Hotel
{
    public string Description {get;set;}
    public Address Address {get; set;}
    public List<Image> Images{get; set;}
}

And of course make constructors.
Office initialization will be like this
var office = new Office(
                new Address(country, city, street, houseNumber), 
                new List<Employee>(),
                new List<Tour>(),
                new Contacts { Email = "[email protected]"} 
                );

S
Stanislav Makarov, 2015-10-24
@Nipheris

"Is it normal to create a bunch of instances of other classes in each class?"

And you understand that if you are concerned about the code you provided, you need to think not about classes, and not about performance, but about functions and methods. Zelim Beltoevalready well hinted to you about this, I will say it again in words: the fact that there are a lot of OBJECTS and complex connections between them is NORMAL. The most important thing that you should be able to limit is the complexity and volume of connections in a SPECIFIC section of code. As long as you understand WHAT you have written in a specific method, and HOW it behaves (moreover, this understanding does not diverge from reality) - you are doing everything right. This is the most important criterion. Performance is also a factor, but I can't even imagine how complex the class structure needs to be invented to really prevent the same CLR from executing code. Real bottlenecks on the way arise in algorithms with high algorithmic complexity, there are usually few such places (if they exist at all, in business applications in 99% of cases everything depends on IO, or the need to cache more on the client),

M
MrDywar Pichugin, 2015-10-25
@Dywar

I myself was looking for good lessons on this topic, but did not find any (so that everything would be shown in full on the fingers: D).
Read msdn -> Class Library Development Guide

Правила именования
Описывает правила именования типов и членов в библиотеках классов.

Правила разработки типов
Описывает правила по использованию статических и абстрактных классов, интерфейсов, перечислений и структур.

Правила разработки членов
Описывает правила разработки и использования свойств, методов, конструкторов, полей, событий и операторов. В данном разделе также описываются лучшие методики разработки.

Разработка с обеспечением расширяемости
Описывает правила по проектированию расширяемых библиотек.

Правила разработки исключений
Описывает правила по проектированию, генерации и обработке исключений.

Правила использования
Описывает правила использования массивов и атрибутов, а также правила реализации операторов равенства.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question