- Java 9 with JShell
- Gastón C. Hillar
- 1020字
- 2021-07-09 18:46:46
Identifying objects from applications requirements
Whenever you have to solve a problem in the real world, you use elements and interact with them. For example, when you are thirsty, you take a glass, fill it up with water, soda, or your favorite juice, and then you drink. Similarly, you can easily recognize elements, known as objects, from real-world scenarios and then translate them into object-oriented code. We will start learning the principles of object-oriented programming to use them in the Java 9 programming language to develop any kind of applications.
Now, we will imagine we have to develop a RESTful Web Service that will be consumed by mobile apps and a web application. These apps and applications will have different user interfaces and perse user experiences. However, we don't have to worry about these differences because we will be focused on the Web Service, that is, we will be backend developers.
Artists use different combinations of geometric shapes and organic shapes to create art. Of course, creating art is a bit more complex than this simple definition, but our goal is to learn object-oriented programming and not to become experts in art.
Geometric shapes are made of points and lines, and they are precise. The following are examples of geometric shapes: circles, triangles, squares, rectangles.
Organic shapes are shapes that have a natural look and have a curving appearance. These shapes are usually irregular or asymmetrical. We usually associate things from the natural world, such as animals and plants, with organic shapes.
When artists want to create abstract interpretations of things that would normally require organic shapes, they use geometric shapes. Imagine that Vanessa Pitstop is a painter and craftswoman. She started uploading videos about her artwork to Instagram and YouTube a few years ago and reaches a great milestone in her artistic career: San Francisco Museum of Modern Art prepares an exhibition of her most important artwork. This special event generated a huge impact on social networking sites and, as usually happens, there is a new software development task related to this important boost in popularity.
Pitstop is an extremely popular YouTuber and her channel has more than four million followers. Many Hollywood actresses bought their artwork and uploaded selfies on Instagram with her artwork as a background. Her exhibition generated a huge additional interest in her creations and one of the sponsors wants to create mobile apps and a web application that reproduce her artwork based on geometric shapes and provide details about the all the tools and the acrylic paint that the user needs to buy to produce the artwork.
Pitstop sketches basic shapes and then paints them with acrylic paint to build geometric patterns. The mobile app and the web application will use our Web Service to build Pitstop's predefined patterns, based on the canvas size and some predefined color schemes selected by the user. Our Web Service will receive the canvas size and the color scheme to generate the pattern and a bill of materials. Specifically, the Web Service will provide a list of the different tools and the acrylic paint tubes, jars, or bottles that the user must buy to paint the drawn pattern. Finally, the user will be able to place an online order to request all of some of the suggested materials.
The following image shows a first example of Pitstop's artwork with geometric patterns. Let's take a look at the image and extract the objects that compose the pattern.
The following objects compose the geometric pattern, specifically, the following 2D shapes from top to bottom:
- 12 equilateral triangles
- 6 squares
- 6 rectangles
- 28 circles
- 4 ellipses
- 28 circles
- 6 rectangles
- 6 squares
- 12 equilateral triangles
It is fairly simple to describe 108 objects or 2D shapes that compose the pattern. We were able to recognize all these objects and to indicate the specific 2D shape for each of them. If we measure each triangle, we will realize they are equilateral triangles.
The following image shows a second example of Pitstop's artwork with geometric patterns. Let's take a look at the image and extract the objects that compose the pattern.
The following objects compose the geometric pattern, specifically, the following 2D shapes from top to bottom:
- 12 equilateral triangles
- 6 regular pentagons
- 6 rectangles
- 24 regular hexagons
- 4 ellipses
- 24 regular hexagons
- 6 rectangles
- 6 regular pentagons
- 12 equilateral triangles
This time, we could describe 100 objects or 2D shapes that compose the pattern. We were able to recognize all these objects and indicate the specific 2D shape for each of them. If we measure each pentagon and hexagon, we will realize they are regular pentagons and hexagons.
The following image shows a third example of Pitstop's artwork with geometric patterns. In this case, we have a huge number of 2D shapes. Let's take a look at the image and just extract the different 2D shapes included in the pattern. This time, we won't count the number of objects.
The pattern includes the following 2D shapes:
- Equilateral triangles
- Squares
- Regular pentagons
- Regular hexagons
- Regular heptagons
- Regular octagons
- Regular decagons
The following image shows a fourth example of Pitstop's artwork with geometric patterns. In this case, we also have a huge number of 2D shapes and some of them intersect with each other. However, we will still be able to recognize the different 2D shapes if we pay some attention. Let's take a look at the image and just extract the different 2D shapes included in the pattern. We won't count the number of objects.
The pattern includes the following 2D shapes:
- Regular pentagons
- Regular decagons
- Circles
- Equilateral triangles
- Squares
- Regular octagons
The following image shows a fifth example of Pitstop's artwork with geometric patterns. In this case, we will recognize the shapes from left to right because the pattern has a different orientation. We have many shapes that intersect with each other. Let's take a look at the image and just extract the different 2D shapes included in the pattern. We won't count the number of objects.
The pattern includes the following 2D shapes:
- Circles
- Regular octagons
- Equilateral triangles
- Squares
- Regular octagons