R
R
Rutherfordium2018-10-27 00:40:07
Java
Rutherfordium, 2018-10-27 00:40:07

What is the best way to organize the class structure?

Hello.
I am getting acquainted with OOP and decided to write a small project using mvc. A simple console application that prints weather data given input into the console. A little more detail:

  1. User enters data (city, district, etc.)
  2. The application sends a request to the Yandex.weather API, for example
  3. The received data is somehow parsed
  4. Displayed to the user

How to organize the class structure most competently, taking into account mvc (or without it, if it is more convenient)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Iloveski, 2018-10-27
@Iloveski

If mvc, then in a simple application there are 3 packages: controller-class (classes) accept a request from the user and pass it to the model. In OOP mvc there is no business logic in the controller. model - it contains data structures, business logic (working with api in your case), parsing. It can be divided into subpackages within model. View - a class (classes) accept a ready-made object (objects) and display it on the screen, as needed.

H
Hungry, 2018-10-27
@hungry-devel

Examples of how this can be organized:
Phalcon MVC Examples

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question