Technical Overview Document - Juan Molina
Technical Overview Document - Juan Molina
Intro:
The purpose of this document is to provide a brief overview of the main projects I have
participated in building during the past years.
Instructions:
The structure and steps for this document will be as follows:
Final message:
Before you begin, I want to say that I am still an entry-level developer maturing and I
worked with other lead developers who advised me. However, I do want to say that I
gained plenty of experience and to master basic and intermediate understandings.
Part of why I want to work at the University with CADSWES is because I want to keep
growing, learning and apply new skills alongside the specialization of my master’s
degree.
Thank you!
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
Project #1
Games in Unity3D
Problem:
When I first started at the Bolder Game’s organization, the previous DevOps and some
senior developers quit. They left a project that was malfunctioning, had no proper
documentation and games with old code. The principal was worried the projects would
shut down and eventually die because it had no adaptability and readability for future
developers.
Solution:
Therefore, I decided to improve the code quality by implementing the right OOP
principals and re-make old games. To do this, I had to inspect and refactor code,
implement new UI and non-UI elements, and run tests on specific chunks of code for
games built in Unity3D. I had to completely restructure existing C# code to improve its
design while preserving functionality.
Items used:
a. SOLID principles.
b. C# writing standards.
c. UI and C# events.
d. Unit Testing.
Process:
As a small example, in one of the games there was a functionality to highlight a material
on selection. It was a manager script with more than 100 lines of code (not good), so I
decided to apply the object-oriented paradigm.
The selection class basically was responsible of three things. Selecting, deselecting and
listening to a ray from the virtual camera every frame to decide selection.
using UnityEngine;
_selection = null;
if (Physics.Raycast(ray, out var hit))
{
var selection = hit.transform;
if (selection.CompareTag(selectableTag))
{
_selection = selection;
}
}
if (_selection != null)
{
var selectionRenderer = _selection.GetComponent<Renderer>();
if (selectionRenderer != null)
{
selectionRenderer.material = highlightMaterial;
}
}
}
}
1. I first applied the single responsibility principle rule which says that every class
should be responsible only for a single piece of function. Hence, I break the
selection manager down on what is doing in each part.
using UnityEngine;
_selection = null;
if (Physics.Raycast(ray, out var hit))
{
var selection = hit.transform;
if (selection.CompareTag(selectableTag))
{
_selection = selection;
}
}
#endregion
// Deselect/Selection Response
if (_selection != null)
{
var selectionRenderer = _selection.GetComponent<Renderer>();
if (selectionRenderer != null)
{
selectionRenderer.material = highlightMaterial;
}
}
}
}
2. Then I make responsibilities into their own method, so the selector manager is
responsible only to delegate tasks. Then start to follow the open/close principle
to simply open a new method for modification to extend without having to add
more code.
using UnityEngine;
// Deselect/Selection Response
if (_selection != null)
{
_selectionResponse.OnSelect(_selection);
}
}
}
4. Then I implement brand new behavior without having to extend the selection
manager. Following again the open and closed principle.
public class OutlineSelectionResponse : MonoBehaviour, ISelectionResponse
{
public void OnSelect(Transform selection)
{
var outline = selection.GetComponent<Outline>();
if (outline != null) outline.OutlineWidth = 10;
}
5. Then split up the interface selection manager to sperate responsibilities that get
their own interface. Which follows the interface segregation principle of saying
that you can take more advantage of the nature of object-oriented design by
having many specific interfaces.
This way in the future I can add new behavior that can simply inherit from the universal
interface and I do not need to extend the class by adding more lines of code.
Assignment #2: Create unit tests and clean code
One of the games had a health system for a player class that showed the change by a
heart image and text. In order for me to test the function, I decided to write a unit test
function and algorithm.
using NUnit.Framework;
2. Write a Summary
a. Write a suppose statement.
b. Write goal assignment.
c. State a problem to prove from the assignment.
i. How this will help me write the code for the assignment.
d. Write a list of requirements.
i. Parameters.
ii. Methods.
/// <summary>
/// Suppose: What if a player increases its health and gets shown in the UI?
/// Goal: Display a health bar in the form of text and image for a player.
/// Problem: Can health be increased using text and image feedback?
///
/// List of requirements:
/// 1. Player: Class.
/// 3. Heart Graphic: Image
/// 4. Text: Text
/// 5. Increase Method.
/// </summary>
[Test]
//ARRANGE
int _health = 50;
float _fill = 0.5f;
using UnityEngine;
using UnityEngine.UI;
iv. Then I create the player class inside this same test script, following
the Open/Close Principle. With its constructor that I know deals
with a text and an image. Also, include a increase health method.
_player.IncreaseHealth(50, 0.5f);
f. Use Test Runner. In the editor of Unity3D I could run these tests and see
if my test script would be successful.
//ACT
_player.IncreaseHealth(50, 0.5f);
//ASSERT
Assert.AreEqual(actual: 100.ToString(), expected: _text.text);
Assert.AreEqual(actual: 1, expected: _image.fillAmount);
}
After I was done doing the test script, I went and refactored the code to improve the
design.
4. Clean code
a. Start noticing patterns
b. Adding regions.
c. Add Global Parameters
[SetUp]
public void BeforeTests()
{
_image = new GameObject().AddComponent<Image>();
_text = new GameObject().AddComponent<Text>();
_player = new Player(_text, _image);
}
e. Following the SOLID principle of Liskov Substitution Principle and Derive
Inversion Principle.
using UnityEngine.UI;
As I was re-making one of their old tablet games. One of the challenges was that how
was I going to translate an entire old swift code game from MAC. Well I simply decided
to implement that from scratch with the help of Unity3D’s editor-based UI system
2. With the Unity graphical editor UI system, I added a button function component
that has an OnClick() event that calls my menu controller script.
Then I was challenged with how I would make the game know when the info or the help
menu are closed, etc. Therefore, I decided to make non-UI event for this case by an
event delegate model with C#.
1. I first created a new class that would handle events as a service for my scripts.
This would act as a listener for references of event methods. In this case of
closing.
public class ListenerInfoMenu : MonoBehaviour
{
public EventContainer containor; // may assign from inspector
void Awake()
{
containor.OnClose += Containor_OnClose;
}
void Close()
{
Debug.Log("OnClose event fired");
if (OnClose != null)
{
OnClose(Time.time); // passing float value.
}
}
}
--------------------------------------------------------------------------------------------------------------------
Project #2
Install Full Stack Web Application with Database in Linux Distro
Problem:
The Bolder Games organization was almost at the end of an important product delivery
of a war simulation for one of their clients. The engineering principal was worried
because still at that point, they had not been successful to provide a successful end-to-
end test. Moreover, they needed to show an automated build service of the product to
compete with others.
Solution:
Therefore, I volunteered to provide him a solution to acquire its end-to-end test by
learning and helping to install and configure an object-relational database with an
intelligence web application on a Linux distro virtual machine.
Items used:
a. PostgREST databse that extends and uses SQL.
b. Apache Superset web application that integrates SQL speaking relational
data bases for with Object-Relational query databases and provides with
an intelligent environment for visualizations of the data.
c. VirtualBox to create Virtual Machine of Ubuntu OS.
d. Docker container.
e. Object Relational Database knowledge.
Process:
Assignment #1: Install and Configure ORDB with Superset on Linux Virtual Machine
First, I decided to start by planning out the design as the first consideration. From the
data storage container with the PostgREST database to the superset web application
that will show data visualizations inside web client with Mapbox.
Also, consider the purpose of this DB which is to portray data visualizations based on
metrics gained from a war simulation.
Diagram:
Then, we considered the metrics we needed to use also to decide the naming
convections and datatypes to use when designing the schematics for the database.
Confirmed Metrics:
Then installed superset inside a Docker container. That packages software into
standardized units called containers that have everything the software needs to run
including libraries, system tools, code, and runtime. The advantage of doing this is that
it makes it easier to deploy and run applications repeatably.
1. An advantage is that it stores data on disk in the binary json format pretty well
which provides support for various data types to be nested inside each other.
However, the disadvantage in our case was that MongoDB is not relational, so we would
not be able to exchange or join. And, we knew that we were going to need queries to
manipulate data and that our data would be changing from the simulation!
So, we determined the usage pattern for this database can be simple as data stored in
object tabular form with postgREST and superset because it would create an object
relational database.
List of Relations:
Then by installing a postgREST database with a REST API which for its database access.
With this, our chosen relational database (postgREST) with the basic form of tables
containing rows and columns components can be combined with an object-oriented
database model in its schemas by its modeling function. By providing the connection of
a relational database system and the mapping of the relational model thanks to the
apache superset web application. This is when object-relational databases come in
handy to fit purely relational databases into the object-oriented frameworks.
--------------------------------------------------------------------------------------------------------------------