Discitur Project

1 minute read

In the first sprint was making a simple controller that displayed the data in a lesson. The lesson is a entity composed of several sub-entities. The structure that I foresaw in front-end is:

  • Lesson (title, school, classroom, content, rate, publishedOn, etc)
    • Author (name, surname, etc)
    • Good Practices List (lesson’s pro)
      • Good (description)
    • Bads Practices List (lesson’s cons)
      • Bads (description)
    • Tags List

For the approach defined in the Refining Cycle I developed the FE with the mock service, I checked with the PO the result and then I realized the back end. On Back-end side I found most suitable to provide a model (entity-table) providing for a single Entity/Table LessonFeedback to enter both the pros and cons of a lesson, differentiating through the “Nature” attribute of FeedBack

At Back-end side, my entity model is something like the following: 

  • Lesson
    • Author (name, surname, email, userName, etc)
    • FeedBacks List
      • FeedBack (Nature, description)
    • Tags List

This approach and the scenario itself, in fact, is very common in a lot of enterprise scenarios, it happens that:

  • there are separate groups for analysis and development of the FE and BE
  • there is already a dictionary of services (SOA, REST, etc. ..) ready to use that return the data you need. None Back-end developer will make a copy of an existing service to give you back the structure that you expect on the FE. And it’s usually right.

I always find it useful and important, therefore, to mark a clear line of separation between FE and BE for a lot of reasons. That’s why, even without having to deal with remote systems, I like to implement DTO classes for transferring data from an Object Model services to the needs of the specific front-end.

In Angular, I realized all through the use of Services and Promises, below are some useful articles (beyond the official documentation):

 

That’s the code.

 

Now the controller becomes simple

 

and its template works on an Object Model decoupled from Back-End. 

 

This design has the advantage of reduce future reworks due to changes in the backend service that does not require changes to the user interface to just the LessonService code.

Comments