King of Adem

The latest personal project I am working on which also happens to be the largest personal project I have worked on so far.

King of Adem is a game for tabletop minature wargamers. Players manage their kingdom through the app. Kingdoms consist of a number of a territories, each player starts with one.

In each territory their is a capital city in which buildings can be constructed. Buildings provide benefits like more money or the ability to recruit armies.

When 2 armies collide by moving into each other the players can then resolve the battle as normal by playing their normal game of tabletop minatures.

The game takes place on an island called Adem. Adem is a recently discovered island where each player is fighting for control. You fight to become the “King of Adem” by conquering the whole island.

Although Adem is stated as “recently” discovered, this only means “recently” in the grand scheme of things. Adem actually has a number of Kings / Factions already on the island and each Kingdom has some infrastructure.

The project is currently divided into 3 parts …

King of Adem Diagram

Part 1 – Game Server
The Game Server is currently in construction and is being developed using the Yii 2 framework written in PHP. The database is MySQL. The server takes view requests and command requests from the client application.

View requests provide data to the client in JSON format. This data has everything needed to render views for the game for example, building, army, territory data.

Command requests provide data to the server about interactions happening in the client application. For example move commands, construct building commands etc.

The decision to use View / Command requests was chosen instead of opening the server up entirely.

Essentially one option could have been for each Data model on the server to have a view, insert, update, delete request to use for either commands, views or both.

This would give the client more freedom at the cost of putting more logic onto the client.

As the first client is being developed using IOS and IOS uses a view per screen type of structure then View requests make sense. Giving the client the exact data the client needs in order to render the view.

Part 2 – Game Test Client
The Game Test Client is currently being developed alongside the Game Server and serves as a testing ground for the development of the server.

The Game Test Client can send View requests to the server and read / present the data from the server in a user friendly way. The Game Test Client can send command requests to the server.

The Game Test Client is being developed using the Yii 2 framework written in PHP. The Game Test Client is my own personal client for testing the server and is not the actual client the end user / player will be using.

Part 3 – IOS Game Client
The IOS Game Client is the actual client the end user / player will be using to play King of Adem. The IOS Game Client as you might have guessed will be an IPhone application. There may also be the ability to run the application on the IPad as well.

I decided to develop the IOS Game Client because I wanted the game to be portable and it cannot get much more portable than having the game on your phone.

I also choose the game to be an IOS application because I want to improve my IOS skills and offer IOS development as part of the everyday services I offer to my clients.

Once these 3 parts are complete the game will be playable and released to the public. Part 1 and 2 are already in construction, Part 3 will be constructed after parts 1 and 2 and completed.

After the game has been released to the public, a number of other client applications could potentially be developed including an Android version and a full game client developed in Unity3D or similar.

The IOS client will be more management like as opposed to a graphical game. The IOS application could include graphics etc, but it will not be at the level of a full game like experience. This is why I suggest a later developed Unity3D or similar game engine development.

I will be keeping everyone informed of the development of this game through the blog so keep checking back for further updates.

Yii / Yii2 checking controller params at the access control level

One of the areas I notice in a lot of Yii / Yii 2 web applications is the checking of parameter variables in what I consider the wrong areas.

Here is an example of one of my controller methods for saving a Book …

So what stands out about this method? No load Model method? No checking to see whether the Book has a valid ID? How will we know whether the Book has a valid ID, how will we know whether the Book is suppose to be accessed by the particular user that is logged into the system?

The answer is, the access rules and bizrules of the web software application. All controller methods should be assigned to an access rule. If the controller method contains parameters then the controller method should be assigned to an access rule as well as a bizrule.

For smaller / less complex applications you can actually emulate the bizrule by using “matchCallback” which is spoken about in this article I wrote previously …

http://www.jamesbarnsley.com/site/2017/06/13/yii-2-user-permission-using-matchcallback/

You can also read my previous article on what I think of the Yii / Yii2 load Model method …

http://www.jamesbarnsley.com/site/2015/04/22/yii-loadmodel-method/

All controller parameters should be checked and validated in the bizrule, by the time the parameter reaches the controller method there should no need to have any checking in the controller method at all for the controller parameters.

If the Book does not exist or the Book is not accessible by the current logged in user then that will be handled before any controller method code gets executed in the first place.

There is no reason to have this level of checking in the controller method itself. Doing it the way I have described also keeps the controller more clean as extra code is not needed to check the controller parameters.

Retaining great employees

There is talk on the web about retaining great employees and the way some of the articles are written about the subject you would think a lot of companies have a real struggle to get and keep great employees.

Not sure what makes the employees “great” employees other than the fact that if they are the ones leaving the company they obviously have options elsewhere.

So what would I do if I had a company with employees and I wanted to retain them without going over the top and paying them huge salaries obviously …

Allow home working

If your company is in a position to do this, allow the employees to work from home as and when they choose to.

Less hours in work day

Expect 5 hours “in the zone” work from each employee each day but pay them for 7.5 / 8 hours.

Allow the employee to revise skills, have breaks / lunch, collaborate with coworkers, work on personal projects, exercise or even depending on your limits allow the employee to occasionally take the rest of the day off in the 2.5 / 3 hours spare.

Alternatively if the employee really wants to, the employee can carry on with his / her workload. It is up to the employee what he / she spends the 3 hours doing each day.

Companies bill work out at huge hourly rates, contract employees get paid rates that for the most part are 3 or 4 times higher than a standard employee.

If your employee earns £30,000 a year that equates to around £15 an hour at 8 hours work per day, at 5 hours work per day it equates to £24 an hour. What difference do these kinds of low figures make when you are billing clients out at £75+ an hour?

You are still making a huge profit on the employees hourly rate, do you really need to squeeze them for the full 8 hours to get your moneys worth?

Lets see …

Company 80 billable hours per day …

80 hours * £75 = £6000.

Employees cost per day …

80 hours per day at 10 (8 hour) employees at £1200 per day.
80 hours per day at 16 (5 hour) employees at £1920 per day.

The difference in money is £720 per day to offer the above system of working. Yes you have to provide for another 6 employees as well however at least you can gain the satisfaction of having a larger workforce.

The biggest bill is going to be the wages the rest of the payments for employee equipment etc is going to be far less.

Yes the system does cost money but it is the difference between making £4800 and £4080 per day.

Please note if its contract jobs we are talking about, then I would expect the employee to work the full hours quoted as contract employees are on a high hourly rate, the above only applies to standard employees.

Another alternative to the above “5 hour workday” would be to implement the “4 day work week” essentially the employee works 4 days a week but gets paid for 5 days.

Also note that none of the above ideas are an excuse to compress more or the same amount of work into less time. If that happens then the above advantage has obviously been nullified.

More holidays

20 to 21 days holiday entitlement a year? Increase it. I think for every 8 weeks worked an employee should be able to get around 5 days off work. This will double the holiday entitlement bill from around £2400 a year to £4800 a year on a £120 per day employee.

That would increase the cost from £6 per day to £12 per day for each employee that is an extra £6 per day for each employee. With 10 employees that would cost an extra £60 per day, with 16 employees that would cost an extra £96 per day.

Lunch around a big table together

The whole company should eat lunch together every working day preferably around a big table or multiple tables if needed.

Once a month meal

Once a month take the employees out for a meal, paid for by the company.

A lot of these points do eat into the profits however as stated if each employee is making a significant profit per day i.e. employee costs £15 an hour and is billed out at £75+. Then really a company should be able to afford some of the above described perks. This does however assume that each companies employee is booked out enough to make a profit.

In my multi person company this would not be a problem as I would only employee new employees as the work expands, for example I start out with 30 billable hours per week provided by 1 client. That would be just enough work for myself.

Later on I have 3 clients and 100 billable hours per week that would be enough to employee 2 additional employees as well as myself. If the work subsided then I would downsize the company. It would never be a problem as each employee would be generating a lot more money per hour than what I would paying the employee per hour.

These are the points I would implement in my business if I owned a multi employee business. Not all the points have to be implemented but the more points the better. Obviously if the workplace is toxic then none of the above points apply and employees will leave anyway but that is a different topic of discussion.

Should you reveal your budget?

Should you reveal your budget to a potential web development company / web development freelancer? I am presuming most web development companies and freelancers would say yes.

In my business I work on a day rate so to me it does not really matter whether the budget is revealed or not. If you spend £12,000 you will get a £12,000 web software product, if you spend £36,000 you will get a £36,000 web software product. It does not matter to me exactly what the total budget is, you pay me by the day, when you stop paying the work stops.

Having said that knowing the budget can be important. If you have an idea of what it is you want to create it is important to make sure the budget is really there. There is no point in expecting a £36,000 web software product for £12,000.

I generally try to make sure that the “must have” requirements can be fufilled within the expected budget. After the “must haves” have been taken care of the remaining budget can be used to provide extra “goodies” that would otherwise not be there. Design improvements, extra features, additional reports, sidebar information giving the product the extra polish it would otherwise not have.

An ideal scenario might go like this …

  1. You have an idea of the features you want in the web software product.
  2. We have discussion on those features to make sure anything has not been missed.
  3. I take a look at the budget and decide whether I think I can get the work done within budget.
  4. I break the first couple of features down into tasks and add them to the project management system.
  5. I complete the first couple of features, we have a review and see whether we are on track and budget.
  6. More features are added to the project management system until all features are complete.
  7. At this point we discover that one third of the budget still remains.
  8. The additional budget is used to provide extra goodies.

Please note that the way this article is written can give a wrong impression almost edging to a fixed fee kind of feel. I always work on a day rate and any agreements about what can be done in the time allocated are estimates only.

Generally a £36,000 budget will be broken up over the course of months or a year and will act like a retaineer agreement. Generally in such an agreement the overall budget is never discussed, the contractor is paid for a number of days per month to complete work. This is how I work. However that does not mean that an overall “background” budget does not exist.

So, should you reveal your budget to a potential web development company / web development freelancer? Well in my business the answer would be yes, if you want my “opinion” / “estimate” on whether the proposed feature set will fit within the budget.

As we work with each other you will get a feel of what can be accomplished, at what cost and in what timeframe.

Solution for using DatePickers on forms in Yii2

Sometimes in web software applications we need to collect dates such as a start date or end date using forms. In this article I will be using the Kartik DatePicker widget which can be found here …

http://demos.krajee.com/widget-details/datepicker

For the purposes of this article a master Model will need to be created. I discussed how to create master Models and Controllers in the following article …

Create a master Model and Controller in Yii2

So based on the master Model now being created the article can continue. Add the field to the form using code similar to this. Include the plugin in the form …

Add the field to the form …

In the master Model 2 methods needed to be created …

And …

These methods can be called to save the “date” data to the database from any of the child Models. The best place to call the methods would be in the “beforeSave” and “afterFind” methods as follows …

And …

Depending on how you have setup the validations for the “date” attribute you may need to run the “saveDateFormat” and “dateFormat” methods in the “beforeValidate” and “afterValidate” methods as well as the “beforeSave” and “afterFind”.

This depends on whether your validations are formatting the date as the date would be saved to the database or validating against the format the date appears on the form.

If your validations validate against the format the date saves to the database then calling “saveDateFormat” and “dateFormat” methods in the “beforeValidate” and “afterValidate” methods will not be needed.

I generally setup my validations so I do not need to run the “saveDateFormat” and “dateFormat” methods in the “beforeValidate” and “afterValidate” methods only through the “beforeSave” and “afterFind” methods.

Using the above code you can implement multiple datepickers on the same form or across different forms. Follow the same logic, add the field or fields to the form and call the “saveDateFormat” and “dateFormat” methods from the child Model.

I want employees who are emotionally invested in the success of my business

The title of this article was a statement I read recently in an article on the web. There are lot of articles of this nature on the web so the topic is quite recognised. A lot of these articles mix into other subjects, one of those subjects being money.

The title of the topic basically becomes …

I want employees who are emotionally invested in making my company lots of money but I only want to pay them an average or below average salary. Who the hell is going to be emotionally invested that much in the success of your company unless you make it worth their while?

The same people who are sprouting this garbage are the same people who state “do not work for money, work for success” or something of a similar nature. The kind of success these employers are expecting are what I call “life work” success.

To explain, “life work” is something that a lot of people will do in there spare time unless they are lucky enough to be doing it full time. The people who are doing “life work” are people who invent something groundbreaking or write one of the best novels of the century.

George R. R. Martin the person who wrote Game of Thrones which is now a huge success spent years and years of his life writing the novel. This is not something that he is just going to do for some company for an average salary and most likely this is not something he going to do for any company no matter the salary.

When people talk about not working for the money and working for success, this is what they are talking about. It is not something that can be transfered to Uncle Bobs Print Business. This is what Uncle Bob is expecting however and all the people spouting the above garbage, he is wanting the “life work” of someone like George R. R. Martin for the peanuts he is paying him to work for his local print shop.

Somewhere along the line these employers have mixed “life work” and “everyday work” together. They want the benefits of someones “life work” but they cannot have it.

So lets take it a level down. Lets say Uncle Bob is not expecting the “life work” of some individual but is just wanting the same level of emotional investment he himself puts into his business. Right OK, Uncle Bob, how much are you going to have to pay that employee to put in the same level of effort as yourself?

To get the employee emotionally invested to that level he is going to have be like yourself. He is going to have to have a similar level of shares in the business as yourself or alternatively a wage that reflects that many shares.

Uncle Bob wants an employee who will do 100% high standard work, all the time. An employee who will stay late into the night most nights, if required. An employee who will pitch in to help with the administrative and accouting areas of the business after the normal days workload is complete. To expect this level of employee and get this level of employee at an average or below wage is unlikely to happen.

“According to The Intelligence Group, 64% of Millennials would rather earn $40,000 a year at a job they love than $100,000 a year at a job they find unfulfilling. That’s a pretty significant statistic.”

I read the following on a website preaching about the emotional investment of employees. The above in a way kind of backfires on itself because what kind of job are employees most likely to find “unfulfilling”, the kind of jobs where Uncle Bobs are wanting a high level of emotional investment i.e. staying late, high standards without fail, helping into admin / account areas of business after hours.

The exact kind of unfulfilling roles are the exact kind of roles that employers in this article are wanting their employees to invest in. So I am not sure what exactly the above quoted statement is getting at? What it seems to be implying is that Uncle Bob can get an emotionally invested employee who is interesting in making his business a success and doing a load of extra tasks to make his business a success for a 60% paycut.

Infact the opposite is the case, Uncle Bob generously agreed to pay said employee $100,000 a year, said employee got fed up with being expected to invest so much of himself into the business so quit the job and took a regular $40,000 year job where so much investment was not required.

I personally believe that companies can get emotionally invested employees. However to get the level of emotional investment the employer requires, shares would have to given to the employee or a wage that reflects that many shares within the company. Obviously the company has to be quite profitable as well as no one is going to invest in the company if it is only making £10,000 profit. The shares and wage reflective of the shares would then not be worth it.

To me it is just basic common sense, if you want an employee to be as emotionally invested as yourself then the “real” incentive has to be there. I think there is general problem in that the business owner should not be expecting the same level of emotional investment from his employees as what he himself has in his own business.

Tips for clients when choosing a web development company

A while back I wrote a post about tips for freelancers …

http://www.jamesbarnsley.com/site/2016/11/27/tips-for-freelancers/

My goal at the time was to later write an article on tips for clients choosing a web development company. I thought at the time this would be a straightforward article to write but the more I thought about it the less straightforward it become.

Some typical indicators to decide whether a company is worth choosing could be as follows, How many employees does the company have? Are the companies premises any good? How long the company has been in business? Does the company have a decent looking website?

The majority of the above indicators are really indicators as to how well the business is doing. A lot of people will except that if the final product looks and feels right and it works then they are happy with the final product. With a large number of people accepting this as the basic premise most businesses can survive for a long time on this premise.

So what is it I am getting at here? In short, it is the underlying code powering the web development project. It is this area that as the client you will have no ability to judge without programming experience.

Neither did any of the previous clients of the long standing businesses, so the business may be big, the business may have been around for a long while but this does not mean that either you or the previous clients ever got a good product in terms of the code powering the web development project.

How the product looks and to some extent whether the product works or not is merely a coat of paint over the real engine powering the web development product.

A Ford car can look and work right, a Rolls Royce car can look and work right but both have huge differences in the price tag. How do you know whether you are getting a Ford or a Rolls Royce? The quality of the components? In a web development project whilst some of the components may stand out such as the design, some of the components do not stand out i.e. the code.

This article has been born from observing different web development projects with different qualities of code being sold at vastly different prices. The higher priced projects do not nessacarily equate to higher quality code although the project may be of a better quality in other areas.

As a client how can you ensure you are getting quality code? I have thought about this and I am not sure there really is an answer. You could get a programmer contact or external company to inspect the code but then how can you be sure that the external company is any good at programming code, especially since the same applies to the external company which applies to the primary company?

Conclusion
As a client without programming experience maybe it should be excepted that if the company can produce a product which “looks good” and “works right” then the company is acceptable. The quality of the code is hard to determine for the general client and getting the code verified by a third party simply means you have transfered the trust from the primary company to the external company.

Yii 2 User Permission using matchCallback

As a web software developer I sometimes need to implement some kind of user permissions in the web applications that I build. The Yii 2 framework which I currently use has a built in system for doing just this however for applications that need a more lightweight user permission system the Yii 2 framework has introduced a method which was not available in the Yii 1 framework that can be used to easily build lightweight user permissions and that method is “matchCallback”.

Both Yii 1 and Yii 2 have a user permissions system named RBAC. In Yii 1 RBAC is implemented by writing code to define the user permissions, this code then populates the database tables with the user permissions. The user permissions are then applied to controller methods via more code known as access rules.

User permissions can also have what is known as a “bizRule”, a “bizRule” is an additional piece of code executed with the user permission that needs to evaluate to true in order for the user permission to be true. This can be used to implement checks to see if the record being displayed on the page is owned by the user trying to access the page as well as various other checks. The “bizRule” code is stored in the database along with the user permission.

One of the differences between the Yii 2 implementation of RBAC and the Yii 1 version is that the Yii 2 “bizRule” code is stored in code files and not the database. This makes more sense to me as the “bizRule” code is kept alongside the other code in the frameworks, models, controllers, views etc.

Infact it makes so much sense that during the later stages of using the Yii 1 framework I actually just stored class / function references in the “bizRule” code and wrote my real “bizRule” alongside the rest of framework code. Essentially implementing my own version of what Yii 2 covers as standard.

As mentioned above Yii 2 now implements a method called “matchCallback”. This means for web applications requiring simple user permissions RBAC is not needed as the “matchCallback” can be used to define the “bizRule” directly in the access rules …

So as shown above for web applications only requiring simple user permissions, the access rules are all that are needed.

Technical questions on interviews? High standards?

So I have been to a number of interviews now where I have had to answer technical questions and do technical tests. The technical questions are of a high standard and can go deep into the principles of object orientated programming. What baffles me is when I ask to look at some of these companies codebases the codebase is a mess, even the interviewers have admitted that their own codebase is a mess occasionally.

I am talking functions with over a hundred lines of code in them, huge code files, code copied from one place to another with just a couple of minor changes, no consistency in naming conventions, if “classes” where used no real thought about true object orientation was attempted and the class was used just as a place to put some code.

Now the company may state they have high standards during the interview process to weed out the candidates who do not do well in the tests. However this makes no sense for a couple of reasons …

  1. True candidates who do well on the tests may not want to work on such a codebase. Even if the candidate who did well on the tests did want to work with such a codebase how can the candidate who did well on the tests adapt to such a codebase? All the candidates who did well on the tests can do with such a codebase is to follow what is already there for the most part.
  2. Companies with such a codebase do not want candidates who do well on the tests, the companies may claim they do but when it comes down to it the candidates suggestions for improving the codebase will not be taken seriously. Generally with codebases like these a complete re-write of the entire codebase will be required. Companies with codebases like the above suggested do not care whether someone can code the system in a more efficient and effective way, they just want someone who can work with the codebase they currently have.

Please note, I am not saying there is anything wrong with having different standards of code. I can adapt to different codebases and different standards of code infact adapting to what is there already is probably the best way of working with the codebase. I am merely wondering …

Why the high level technical questions and tests in the interview?

Who knows? I most certainly do not. None of the principles asked during the interview is applied to the companies codebase so why do candidates need to go through these tests and demonstrate such principles.

Earlier in the writing of this article you may have thought I was being harsh and judgemental when I was talking about the mess codebase. Like I say I am not bothered about the mess codebase if the mess codebase is already there and that is what the company has.

Sometimes codebases can become a mess if multiple people have worked on the project and there is no one there to really hold the architecture of the project together. I am not being judgemental in a harsh way, what I am argueing is why hold employees to high standards in interviews when it is obvious the codebase is a mess anyway.

It is like expecting 1 employee to do everything to a high standard on a project that has no standards. So that 1 employees contribution to the whole big project has to be to high standards whilst the rest of project can have no standards at all. Laying the burden on the 1 employee whilst the rest have not done anything to any reasonable standards anyway.

The best interview I ever had consisted of having a small conversation about myself and the company followed by a small task. The small task I had to complete was to demonstrate how I would fix a certain bug with one of the features within their current system. No tricks, no catches. I just had to explain how I would fix a fairly ordinary bug that has cropped up in the current system.

I was shown a screen with the bug on it and handed the codebase. I could determine the starting point to look for the bug via the URL of the screen with the bug on it. After starting at the above point and digging deeper into a couple more files I found the best place to implement the fix and determined what the fix would be.

It would be great if all interviews where like the one described above. The task has got to be something small that demonstrates the programmer can dig into the codebase and fix a small problem.

So in conclusion I believe that interviews should be tailored to represent the actual companny. If your company does not need candidates who do well on interview tests then the interview should not be tailored that way. If your company is adament that candidates who do well on interview tests are needed then the companies current practices and codebase should reflect the level of tests they are giving to candidates at the interview.

Please also note that in a lot of the tests companies give to candidates the questions seem more geared to how much you can remember from a standard “programmers handbook” than actual real world scenarios that might actually happen. That is why the above approach involving fixing a bug is a better approach in my opinion.

Neptune – web based lead management / tracking tool – going free

Neptune is going free. I spent sometime not long ago implementing the subscription billing system into Neptune. Now I have spent some time to enable Neptune to have a plan that can be signed up to free of charge …

www.neptuneleadtracker.com

You can sign up and use Neptune for free now.

Trying to run Neptune like a business and only have paid plans took the fun out of the Neptune project. With the business aspects of Neptune out of the way Neptune can now be treated like the side project that it really is.