Sunday, July 23, 2017

Innovation Speed — Should you avoid applying UI if you can?

A lot of times, as the technical team in a company, you get pressured to build a self-service tool so that business/product-team can perform their configuration and content changes without involving the tech team.
Should you just build what the business/product teams requested or should you justify why this should not be done in the interest of both the business and the tech team and ultimately in the interest of your end customers?
To question the requirements from your product/business teams, you need to have very good justifications and counter proposals. In a good work environment, the requirements should not just come from business and be executed by the tech team. It should be a two way conversation. The perception is that the tech team just wants to deal with technical details, but the reality is that the tech team wants to be involved at the idea phase before the requirements get baked and turned over for design and implementation. Early in my career I was happy with just focusing on technical details and enjoying the process of solving problems through coding. Then later I realized that my motivation comes from knowing what the business team wants to achieve and for me it meant that I was able to translate that to a much better working software.
Let’s use the Price & Product Configuration and its UI tool as an example. This subject is very dear to me and I have certain vision that I would like to share in order to get to the essence of this article.
Let’s assume you built a set of microservices and database structures behind each service to support the following capabilities:
  • * Creating offers (no UI but configurable) and specifying the price
  • * Creating benefits/features (no UI but configurable)
  • * APIs that allows you fetch offers and query offers in order to decided what offer(s) to display to customers
  • * API that allows you fulfill offers and ultimately create customers’ subscription records
Let’s say these feature are very stable in production, but you still need to continue to iterate and build new capabilities and enhance existing capabilities for the business requirements that are geared towards the end customers.
At the same time you maybe getting business requirements that are are about the self-servicing of these features for internal customers (your product and business team). These requirements are all about above mentioned capabilities of microservices and introducing some UI tool that allows the business team to perform price and product configuration (creating offers, creating benefits, configuring and changing prices for offers, …etc).
The goal purely looking from the tech team’s angle is to have agility and to innovate. When you introduce UI tools on top of your evolving microservices, then it really slows down your ability to innovate and adapt quickly. Why does the building of a UI tool slow you down? Think about the possible impacts if you change the underlining functionality and structure of your microservices:
  • * You will also need to change the UI to accommodate for these changes
  • * You will need to possibly train the users of UI if the changes are drastic enough
  • * And you will need to roll this out without causing too much disruption.
All of this requires a lot of effort and coordination. This effort and coordination is acceptable after you have a mature product in production, but it is too much overhead if you are still rapidly evolving.
If you have a choice, you really need to consider delaying any self-service UI tools for your business until the data structure and microservices for your data structures are mature enough; otherwise, you would be just slowing down the delivery of new features in these microservices for end customers even though the tech team can deliver all the changes that the UI tool would do for business users by just making application config changes. This is a very good alternative during this crucial innovation phase.
Therefore, as the tech team you need to be able to convey this message to your business and propose investments into the capabilities of these microservices for end customers before building a self-service UI tool. But at the same time, you need to provide to business some visibility to the configuration from these microservces so they can better visualize what what capabilities they have so far. That could be just a BETA version of some simplistic UI tool that is about purely REAL-ONLY information . If it is a “read-only” version of this tool, then the effort is much lower and there is less to consider from the security point of view. Overall, I think this is a good compromise for some amount of time to keep the agility at a high level and to keep the innovation going.
Let’s go back to the days when Google released the beta version of GMail. They kept the beta version for quite some time and they informed users that they don’t have any obligations to support customers requests. Why did they do this? They did it because they did not want to slow down the innovation of GMail in its early days by introducing the formal UI; that’s why kept it as a beta version. I am not saying that you should be doing this for as long as Google has done it, but the overall conclusion is the same.
In conclusion, consider delaying building the official self-service UI tools for your product/business users in order to keep the innovation and agility at a high pace during crucial phase in the evolution of your microservices and data structures/configurations.
Thank you for reading this article. Please follow me here on Medium.com or check out my personal blog: http://www.almirsCorner.com
Almir Mustafic




Code to get around the process OR Code it right and improve your deployment methodology and the process

Code is just code. Process is just process. However, when you combine the two, they impact each other in ways that they should not.
Let’s assume you built a platform for your team. Then the process came later and slowed down things but kept things as stable as possible. Then software engineers realized that they can follow the process and do the development in such a way that they can go quicker through this process. I am talking about writing code that is so over-configured that it actually allows you to deploy changes to production quicker just because it is a configuration change that you are deploying. When your platform is over-configured, the weight of a configuration change is so huge that you can introduce functional changes to the degree that makes you wonder if you are adding so much risk to the business because you are taking a shorter path in the process workflow. The risk is there because software engineers don’t feel comfortable making these heavy-weight configuration changes and nobody likes doing any change in the engine of the code that drive this heavy configuration.
This really smells as coding to get around the process. Is this right?
I am all about automating the process, but when it comes to over-configuring your code just for the purposes of getting around or going quickly through the process, it is totally wrong.
As a software engineer or a technical lead, every time you find yourself thinking how to adjust the code to make it very configurable to get around the process, you should ask yourself the following questions:
  • How can I help automate or implement the continuous integration in such a way that I can do the right thing in my code. The right thing could be that you actually make a code change that requires a compilation, build and deploy and the code instead of trying to make it configurable and complicating your codebase and increasing maintenance costs.
  • How can I work with the Change Control team and improve the SDLC/PDLC process in order to make it jive with the platform/framework you have implemented in your company.
It is ok to have a simple code change instead overcomplicating the code to make it configurable so that you change ends up being a configuration setting.
In conclusion, it is important that you design your process at the same time you are building your new platform. That’s how they compliment each other better. As for software engineers, please don’t code to get around the process. Please code it right and identify incremental changes how you can improve your software deployment approach.
Thank you for reading. Please follow me here on Medium.com or check out my personal blog: http://www.almirsCorner.com
Almir Mustafic





Sunday, July 9, 2017

Figure out a solution before you open a book of design patterns — Quick Advice

A lot of times software developers get caught in the situation where they are reaching for the book of design patterns to see how they could solve a specific problem.
Programming languages are rich enough to help you solve different problems and a lot of programming languages and its frameworks can be used to easily implement different design patterns. However, when something like this is readily available to you, you need to have enough discipline NOT to reach for it right away.
What do I mean by this?
It is important to first truly understand what problem you are trying to solve. Work with your product owner and make sure that requirements are true business requirements without inclining any type of implementation. Once the requirements are in good shape, then you know what problem you are trying to solve.
Then you need to work out different solutions for that problem. This is where you would use your overall software engineering experience. You should NOT open a book of design patterns and look for what could solve your problem, but you would rather work out a solution and then if it happens to be one of the known patterns, the implementation of it would be that much easier.
Please think about this any time you are presented with a problem to solve.
Thank you for reading. 
Almir Mustafic





Friday, July 7, 2017

Plotting graphs with Python — Simple example

As plotting graphs is something that my oldest kid started doing in school, I decided to finally spend some time doing it in Python. This article is about the basics, but I will also later get into the calculations of medium, mean, mode and other more complex concepts of plotting graphs using mathematical formulas.
Here is an example that shows you the following:
  • * takes a list or more lists and plots it on the graph
  • * plotting of points on the graph with or without connecting it into lines
  • * applying the labels on the x-axis and y-axis
  • * applying the overall title on the graph
  • * adjusting your scale based on what type of data you have for each axis
Install the following libraries before running the code below. By the way, the example is written for Python 2.7.x:
pip install matplotlib
pip install matplotlib-venn
Here is the example that you can play with as it has a command-line menu that allows you to choose which type of graph you want:
__author__ = 'Almir Mustafic'


from pylab import plot, show, title, xlabel, ylabel
from pylab import legend
from pylab import axis


def main():
    print("main program")
    while True:
        print_menu()

        choice = raw_input('Pick from the menu? ')

        if choice == '1':
            plotting_example01()
        elif choice == '2':
            plotting_example02()
        elif choice == '3':
            plotting_example03()
        elif choice == '4':
            plotting_example04()
        elif choice == '5':
            plotting_example05()
        elif choice == '6':
            plotting_example06()
        elif choice == '7':
            plotting_example07()
        elif choice == 'q':
            break

        print("")

def print_menu():
    print("=========================================================================")
    print('1. Plot a few points WITHOUT dots for the given point and connect as line')
    print('2. Plot a few points WITH dots for the given point and connect as line')
    print('3. Plot a few points WITH dots and WITHOUT the LINE')
    print('4. Plot Ladera Ranch town temperature with DOTS and LINE and NO X-Axis specific range')
    print('5. Plot Ladera Ranch town temperature with DOTS and LINE and X-AXIS range specified')
    print('6. Plot Ladera Ranch averages in 1996, 2006 and 2016 for 12 months. 3 graphs')
    print('7. Plot Ladera Ranch averages - Adjust AXIS based on min and max')
    print("q. QUIT")
    print("=========================================================================")


def plotting_example01():
    print("Plotting example 1............")

    x_numbers = [1, 2, 3]
    y_numbers = [2, 4, 6]

    # Plot the line WITHOUT dots for the given points
    plot(x_numbers, y_numbers)
    show()


def plotting_example02():
    print("Plotting example 2............")

    x_numbers = [1, 2, 3]
    y_numbers = [2, 4, 6]

    # Plot the line WITH dots for the given points
    # Markers can be 'o' or '*' or 'x' or '+'
    plot(x_numbers, y_numbers, marker='o')
    show()


def plotting_example03():
    print("Plotting example 3............")

    x_numbers = [1, 2, 3]
    y_numbers = [2, 4, 6]

    # Plot the line WITH dots and WITHOUT LINE
    plot(x_numbers, y_numbers, 'o')
    show()


def plotting_example04():
    print("Plotting example 4............")

    ladera_temp = [53.9, 56.3, 56.4, 53.4, 54.5, 55.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3]

    # Plot the line WITH dots and the LINE
    plot(ladera_temp, marker='o')
    show()


def plotting_example05():
    print("Plotting example 5............")

    ladera_temp = [53.9, 56.3, 56.4, 53.4, 54.5, 55.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3]
    # years = range(2000, 2013)
    years = range(2000, len(ladera_temp) + 2000)

    # Plot the line WITH dots and the LINE
    plot(years, ladera_temp, marker='o')
    show()


def plotting_example06():
    print("Plotting example 6............")

    ladera_temp_1996 = [53.9, 56.3, 56.4, 53.4, 54.5, 55.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4]
    ladera_temp_2006 = [43.9, 66.3, 46.4, 63.4, 34.5, 75.8, 46.8, 65.0, 75.3, 64.0, 56.7, 46.4]
    ladera_temp_2016 = [23.9, 26.3, 36.4, 33.4, 44.5, 55.8, 66.8, 75.0, 65.3, 54.0, 46.7, 36.4]

    months = range(1, 13)

    # Plot the line WITH dots and the LINE
    plot(months, ladera_temp_1996, months, ladera_temp_2006, months, ladera_temp_2016, marker='+')

    # OR you can plot separately like this and the final show() method will know that it needs to plot everything that is queued up.
    # plot(months, ladera_temp_1996, marker='o')
    # plot(months, ladera_temp_2006, marker='o')
    # plot(months, ladera_temp_2016, marker='o')

    # Apply the legend to tell the graphs apart
    legend([1996, 2006, 2016])

    # Apply the TITLE, X-axis and Y-axis label
    title('Average monthly temperature in Ladera Ranch town')
    xlabel('Month')
    ylabel('Temperature in F')

    show()


def plotting_example07():
    print("Plotting example 7............")

    ladera_temp_1996 = [53.9, 56.3, 56.4, 53.4, 54.5, 55.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4]
    ladera_temp_2006 = [43.9, 66.3, 46.4, 63.4, 34.5, 75.8, 46.8, 65.0, 75.3, 64.0, 56.7, 46.4]
    ladera_temp_2016 = [23.9, 26.3, 36.4, 33.4, 44.5, 55.8, 66.8, 75.0, 65.3, 54.0, 46.7, 36.4]

    months = range(1, 13)

    # Plot the line WITH dots and the LINE
    plot(months, ladera_temp_1996, months, ladera_temp_2006, months, ladera_temp_2016, marker='+')

    # OR you can plot separately like this and the final show() method will know that it needs to plot everything that is queued up.
    # plot(months, ladera_temp_1996, marker='o')
    # plot(months, ladera_temp_2006, marker='o')
    # plot(months, ladera_temp_2016, marker='o')

    # Figure out AXIS X and Y min and max and set it for the graphs.
    print(axis())
    xy_tuple = axis()   # returns tuple (x-min, x-max, y-min, y-max)
    my_ymin = xy_tuple[2]
    axis(ymin=my_ymin-20)
    axis(xmax=xy_tuple[1]+6)

    # Another way to set X-min, X-max, y-min, y-max
    # axis([xy_tuple[0], xy_tuple[1], xy_tuple[2], xy_tuple[3]])

    # Apply the legend to tell the graphs apart
    legend([1996, 2006, 2016])

    # Apply the TITLE, X-axis and Y-axis label
    title('Average monthly temperature in Ladera Ranch town')
    xlabel('Month')
    ylabel('Temperature in F')

    show()


################################################

if __name__ == "__main__": main()
Here is the command-line menu that you should see when you run this Python code:

For example, if you select option 6 (graph that uses a lot features summarized above), then you will the following graph pop up:



If you select option 7, then you will see how the scaling on the graph is adjusted explicitly through code:






Almir Mustafic





Sunday, July 2, 2017

Fractions in Python

Doing fractions or math using Python is not something new, but I was anxious to try it out because my kids have been learning fractions in school. So I wanted to be that super dad who can solve the fractions very quickly or at least I could use it to verify their homework.
Here are samples that you can copy and paste into your text editor and try out without needing to do any modifications. These examples are tested in Python 2.7.13 in Mac OS.
Here are some basic examples setting fractions and doing some basic operations. There is also exception handling for zero division:
__author__ = 'Almir Mustafic'


from fractions import Fraction


"""
Playing around with fractions
"""


def main():
    print("main program")

    set_fractions()
    fraction_operations()
    input_and_calculate_fractions()


def set_fractions():
    print("set_fractions method ..............")

    f1 = Fraction(3, 4)
    print(f1)

    f2 = Fraction(8, 4)
    print(f2)


def fraction_operations():
    print("fraction_operations method ............. ")

    fsum = Fraction(3, 4) + Fraction(6, 4)
    print(fsum)

    my_float = float(fsum)
    print(my_float)


def input_and_calculate_fractions():
    print("input_and_calculate_fractions method ..............")

    # Enter for example: 2/3
    # Try entering 2/0 to see how it tells you that it is invalid
    try:
        a = Fraction(raw_input("enter a fraction: "))
        print(a)
        print(float(a))
    except ZeroDivisionError:
        print("Invalid fraction")

################################################

if __name__ == "__main__": main()
Here is a more complete example that allows you to interact with it. You can perform add, subtract, multiply and divide.
__author__ = 'Almir Mustafic'


from fractions import Fraction


def main():
    print("main program")
    perform_fraction_operations()


def perform_fraction_operations():
    while True:

        try:
            print("========================================================")
            fraction01 = Fraction(raw_input('Enter fraction: '))
            fraction02 = Fraction(raw_input('Enter another fraction: '))

            my_operation = raw_input('Perform one the following operations: Add (A), Subtract (S), Divide (D), Multiply (M) : ')

            print("________________________________________________________")

            if my_operation.capitalize() == 'ADD' or my_operation.capitalize() == "A":
                add(fraction01, fraction02)
            if my_operation.capitalize() == 'SUBTRACT' or my_operation.capitalize() == "S":
                subtract(fraction01, fraction02)
            if my_operation.capitalize() == 'DIVIDE' or my_operation.capitalize() == "D":
                divide(fraction01, fraction02)
            if my_operation.capitalize() == 'MULTIPLY' or my_operation.capitalize() == "M":
                multiply(fraction01, fraction02)
        except ValueError:
            print('Invalid fraction entered')
        except ZeroDivisionError:
            print("Zero division fraction. Do NOT do this :)")

        print("========================================================")

        answer = raw_input('Do you want to exit? (yes) for yes or just press enter to continue: ')
        if answer == 'yes' or answer == 'y':
            break


def add(f1, f2):
    print('Result of adding {0} and {1} is {2} '.format(f1, f2, f1+f2))


def subtract(f1, f2):
    print('Result of subtracting {1} from {0} is {2}'.format(f1, f2, f1-f2))


def divide(f1, f2):
    print('Result of dividing {0} by {1} is {2}'.format(f1, f2, f1/f2))


def multiply(f1, f2):
    print('Result of multiplying {0} and {1} is {2}'.format(f1, f2, f1*f2))


################################################

if __name__ == "__main__": main()
Thank you for reading. 
Almir Mustafic



Saturday, July 1, 2017

Car Technology — Who is betting on what technology? Transmissions? Engines?

The technology in cars is very interesting to follow. A lot of innovation is happening around the entertainment systems in cars and the integration with our smart phones. However, there is another part of technology that is kind of happening in the background with car enthusiasts being positively or negatively impacted by the decisions that manufacturers have been making.
I am talking about the strategic approach that car companies have been taking with regards to:
  • * Transmission technology
  • * Engine technology
(1) Transmission Technology:
Here are the current transmission technology choices:
  • * Regular manual
  • * Dual-Clutch Automatics with shifting capability
  • * Traditional automatics with or without shifting capability
  • * CVT with or without emulated shifting capability
It is interesting to see how different car companies are betting on different technologies and it is not clear yet if that is just a tactical approach or long-term strategic approach that they are taking.
We know that regular manual transmissions are slowly going away and there are fewer and fewer choices from year to year. That is not a surprise, but it is definitely not a move that purist car enthusiasts (petrolheads) are fond of.
However, the interesting thing is following the decisions that car companies have been making with regards to Dual-clutch automatics, traditional automatics and CVTs.
For example, Honda is betting on CVTs for all their low-horsepower cars (Fit, Civic, Accord, CR-V, HR-V). However, Acura (their sister company) is betting on the traditional automatics and dual-clutch transmissions (8-speed and 9-speed) that they are for example putting into their Acura ILX, Acura MDX and other vehicles. As a car enthusiast, it makes me wonder if the decision with using CVTs in Hondas is just a tactical / interim decision and ultimately they are putting their bets on dual-clutch transmissions that they have been using in their Acura vehicles. It could be that the dual-clutch transmissions are costly and they are just waiting for the right time to introduce them in Hondas.
On the other hand, Nissan seems to be putting all their bets on the CVTs in majority of their lineup and for their high-horsepower sports cars and SUVs, they are sticking with traditional automatics and dual-clutch automatics.
As for Toyota, it is hard to tell what their direction is. Their hybrids and Toyota Corollas are using CVTs, but the 4-cylinder and 6-cylinder Camry is using the traditional automatics and the newest one even has a rev-matching feature on downshifts. Maybe they are deciding to try the 8-speed traditional automatics on the Toyota Camry to see how it is working out. Maybe that transmission would also be introduced in the new Corolla when it comes out.
On the other hand, Jeeps and Chevy Camaro are betting on their new 10-speed traditional automatic that is supposed to improve fuel consumption and at the same time keep the revs in the power band for spirited driving.
BMW has always been investing into their traditional automatics for their regular line-up and they are just increasing the number of gears and optimizing the shifting. Other luxury car companies are also betting on traditional automatics and dual-clutch automatics.
It is interesting to watch this unfold from the side-lines, and I hope that traditional automatics and dual-clutch automatics prevail even though the CVTs I have experienced in Hondas are really good.
(2) Engine Technology:
Here are the technology choices for engines:
  • * Turbocharged 3-cylinder engines to replace 4-cylinder naturally aspirated engines
  • * Turbocharged 4-cylinder engines to replace V6 engines
  • * Turbocharged 6-cylinder engines to replace V8 engines
  • * Sticking with naturally aspirated 4-cylinder engines and improving efficiency and power with high compression ratio
  • * Sticking with naturally aspirated 6-cylinder engines and improving efficiency and power with high compression ratio
  • * Hybrids with intention to be pure economy choice
  • * Supplementing regular engines with electric power for performance as the main goal and also helping out with the fuel consumption
  • * Sticking with naturally aspirated V8 and V10 engines
  • * Pure electric motors
Governments in many countries are requesting from car companies to improve the fuel consumption and emissions from year to year. Therefore, car companies are under pressure to deliver and many of them have no other choice but to drop the number of cylinders and introduce turbochargers on their engines in order to meet the emission and fuel consumption regulations.
For example, Mercedes and BMW are going with turbocharged engines. They are replacing their naturally aspirated 6-cylinder engines with turbocharged 4-cylinder engines and in this process, they are keeping the horsepower the same while increasing the torque numbers and improving fuel consumption and reducing the emissions.
On the other hand, Honda as always been known for free-revving naturally aspirated engines with low torque, but they actually gave in and started releasing cars with turbocharged engines. Their recent introduction in Civics and CR-V is a 1.5L turbocharged engine that does not have VTEC any more. This is the first time you can say that Civics have torque, but the purists out there are disappointed about the high-revving VTEC being gone. I have owned cars with both free-revving naturally aspirated engines and with turbocharged engines. There is definitely something about the high-revving engines that makes car enthusiasts smile, but on the other hand you have the torque of turbocharged engines that is very practical in daily driving.
As for Toyota and Mazda, they seem to be betting on naturally aspirated engines with higher compression ratios; higher compression ratio helps you with fuel consumption and power gains as well. Mazda MX-5 (Miata), Mazda 3 and Mazda 6 all have naturally aspirated high-compression engines. Toyota is also betting on high-compression-ratio engines with their 4-cylinder and 6-cylinder engines that seem to be promising based on professional reviews.
It is interesting to watch these different tactical and strategic moves unfold in the automotive industry. I am sure that some of these moves will open up the market for some collectibles. For example, Acura Integra Type-R becomes even more valuable with the release of the new Civic Type-R with a 2.0L turbocharged engine. BMW M3 with the naturally aspirated 6-cylinder and 8-cylinder engine will be that much more valuable with the release of new M3 and M4 in turbocharged form.
In conclusion: As car enthusiasts, we are living during fun times when you have very good choices without spending too much money; it reminds me of early and mid 90s when the car scene was blooming.
Thank you for reading. 
Almir Mustafic