Cook php
Published in

Cook php

Creating an MVP during the weekend

The idea of the MVP is to present a new proposal for a system. My customer wants to kick out their vendor for the usual reason: slow, average and expensive (and the vendor is not IBM). When I talk about average, I talk about they developed a system and they are clueless what they are doing it, or they don’t put their heart on it, an old fable said that the lion always gives its 100 percent, even if it’s hunting a small rabbit, so I follow that, I give my 100% or I give nothing.

Joining pieces

My point of view for this project is technical and business.

Then, is it possible to create a MVP in a weekend?. No, but I can’t fail. I also have a date with my dentist that I can’t miss too. I am also working in a different project, that I can’t fail too (but I am working in tandem, it’s an android application).

The goal of the MVP is a backend system for a company that own different stores. This company sells service (that I don’t want to mention).

Friday

Well, it could have started the friday (at night) but I was tired.

Me (the monkey) at the end of the day.

Saturday (7am-11pm)

Unless the project has a visual focus, I always start with the model (database model / or model classes). The idea is simple, the model must be as sufficient as possible (it’s still a MVP) but it is not complete, and it must be fast to design, so I use a mind map to diagram it (I use Xmind application, it’s pretty nice). I could have done a UML diagram but I don’t swing that way (I don’t like UML at all).

Tools that I will use

  • PHP (C# is way faster but PHP smells to freedom).
  • PHPStorm
  • XMind
  • Visio (nah!, I ran out of time for the architecture diagram, I will do it later!)
  • An html template (it includes around 30 javascript libraries), it’s from wrapbootstrap.
  • Mysql
  • A few libraries. I use my libraries. Sadly I found a bug in one of them. I will fix it later.
  • A bit of magic (it is based in a ultra-super secret project :-P )
  • I used a library to generate fake information (fzaninotto/faker). I’m not pleased with the result but It worked.

So I started collecting stuff that I will use.

Why PHP?.

First, I love the language, I can run everywhere (hosting, vps, dedicated, colocation, most are ready to run PHP out of the box), it is easy (and cheaper) to find a host and it’s easy to find a working hands. PHP is the King for websites. Some people could say “but Python”, sorry but no. How many hosting are ready for Python?. Eh?. PHP is a business decision while Python usually is an academic election.

I also use OOP whetever it fits. The usual model of pipeline works with a declarative array

$customer[‘IdCustomer’=>1,’Name’=>’John’];

However, it is prone to misakes and typos (typos that could take days to find), so I will use a model class, so my customer variable will look like

$customer->idCustomer=1;
$customer->name=’John’;

About the model of table, it is simple if not classic

  • Every primary key is marked as Id (unless it is not required). Every primary key must be integer or long.
  • Every other field musn’t be repetitive. Example a column in the table Customers called “name” Instead of “NameCustomer”.
  • The table in plural. It is not a must but it is a good practice.
  • And foreign keys if they are required.

Can I use Mongodb or Redis?. Yes but it cripple to do data analysis, so I skipped it.

Sunday (today)

And now, I am wasting my time writing this article (it’s a joke, right now, I am taking a coffee break).
I start my day with a notification of Google. Some guy (from Iraq) tried to hack my google account.

I added more fields to the model. Silly me, I forget to add money and time.

Then, I started coding.

It is a screenshot of the code. I don’t have time to cleaning the code but it works

About the code, I am not considering the year, tsk tsk.

I use MVC, so I use 8 controller classes, 8 ViewModel, 8 Model, 8 DAO, 8 validators and a bunch of DTO classes (for dao) and 1 webservice. I also created around 70 templates.

It is the stats of the project

23 k lines. It’s not bad

23k lines in 2 days it is not possible using normal means. Some people say LOC (lines of code per day) is around 100, so it could take 230 days. However, for a more optimist viewpoint, it could have taken 100 days.

Now, it’s 11:55pm, I still have 5 minutes.

Now, it is the dashboard. The data is generated from the database (it’s not a static chart). I don’t created the design however, it still a lot of job (specifically, 23k lines)

Dashboard vision

It is one of the screen, It has some bugs and placeholders but it works (I hope it).

Datagrid

And now, the editing screen (with a one-to-many field). However, the button is grey. I must fix that.

Form view

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store