Intro to Modeling and Architecture

Intro to Modeling

CS t-shirt

Most beginner programmers go from problem statement to keyboard entry immediately. In their first two years of programming, almost all of the programs they write are small, so the negative impact of this practice often remains hidden until they approach their first large project - either by themselves or as part of a larger team. In this Unit in the course, the goal is to learn to model a system and build a software architecture before starting to code. As the t-shirt, above, implies, proper planning can greatly reduce code size and overall project development time. While working through this Unit, here are the two main concepts you need to understand:

Fundamentals of Good Modeling and Architecture

  1. The View (the User Interface that the user sees) should be built separate from the internal Model that the computer sees. Almost always it makes sense for the data types used in the View (GUIs, virtual buttons, polygons with distinct colors, etc.) to be different from the data types used to construct the internal Model (integers, decimals, booleans, etc.) This is because the computer is more adept at manipulating numerical quantities than visual objects.

  2. There should be a layer in the software (which we will call the Controller) that will segregate the logic for the app. Other entities in the design should mostly interact with this layer instead of with each other. In the architecture portion of this Unit, we will introduce one such architectural concept called the Model-View-Controller (MVC).

The video, below, provides an introduction to the art and science of modeling a system in computer science. In the example given, a trinary (3-state) model is constructed for a simple tic-tac-toe game. It also describes how the external View differs from the internal Model.

Intro to Architecture

Software architecture is a controversial subject. Like babies, everyone believes that theirs is the prettiest. Even the basic MVC architecture we will describe has various interpretations and options. More important than weighing the pros and cons of various approaches to software architectures is actually having one and being consistent. In this course, we will develop the MVC software architecture depicted below. 

MVC Architecture
The two key features of this architecture we wish to point out are: First, the Model and View are separate software entities for reasons described earlier. Second, a third entity called the Controller contains most of the logic for the application. Note that the Model and View classes interface to the Controller, not to each other. Thus, in this architectural model, the Controller acts as a central brain for the app. In the next section, we will explore this MVC architecture in greater detail, describing which objects and methods in an application should reside in each entity shown above.

Quiz on Modeling

1 point
You have 8 billiard balls, one of which weighs slightly more than the others. You also have a balance scale (a weight scale with two sides). How many weighings will it take for you to discover which ball weighs more than the others?

Project on Modeling

Do the Ants on a Log Project in the list of projects.