WordPress on local machine

When I talked to a friend about learning wordpress development he said why do you want to learn wordpress now? Its an old technology. Now everyone is moving to either Medium or having their own blog developed from scratch.

It’s a true, a reality. With node, MEAN stack, Swift for server side and similar other frameworks a developer can build and run his own site with latest technology. WordPress still works on php, MySQL – the classic xAMP stack.

Why do you want to learn wordpress now? Its an old technology. Now everyone is moving to either Medium or having their own blog developed from scratch.

This doesnt mean we should stop learning old technology which are still doing good. Those are the systems which are still doing good, scaling good. They are thought through and are designed in a better way to last long compared to any new platforms today. I mean Facebook is still powered by php.

This doesn’t mean new technology is not there in terms of scalability. Sad truth is most never get opportunity to scale. Some never see the light of the day and some which get to see hardly have any subscribers and developers of that blog never scale them.

Why am I learning this now?

Learn and understand, experiment, know inside of it and whereabouts of what needs to be done then customize it according to your needs.

  • WP gives a base to start creating your own websites primarily blogs.
  • Lot of templates available or build your own and share.
  • Spend time in customizing as per your needs rather than build from scratch.
  • We can learn how various components are used.
  • Architectures and patterns followed.
  • The schema design.
  • Its always interesting to learn old technologies.

This is the reason why I went ahead with starting on wordpress. As a first step I wanted to install wordpress and try some themes and plugins. But to install I need a server to host and need a database hosting too. Next I searched for how to install WordPress locally on my system? got the results.

It needs a xAMP stack – Apache-MySQL-PHP either on Linux, macOS or Windows. I have a macOS. Now next come how to start a Apache server? After some searching on internet Found MAMP which makes your task very easy. MAMP is for macOS and Windows too and there is another one WAMP for windows only.

There is no better way to have a server of your own for free and do your experiments. And the only best way for this full freedom installing it locally on your system.

Install WordPress locally:

  • Download MAMP
  • Install MAMP or WAMP as per their site
  • Download WordPress Remember this is wordpress.org not .com
  • Unzip the downloaded wordpress file, you must get a folder – wordpress
  • Copy the wordpress folder into installed MAMP folder’s htdocs folder*
  • Now click on Start servers
  • Once the loading spinners stop and you see green in front of Apache and MySQL your servers are running
  • Open your favorite browser and type http://localhost:8888 and hit enter
  • Set up database –
    • Go to localhost/phpmyadmin
    • Go to Databases, add a name for the table and click Create
  • Configure WordPress –
    • Now open a browser tab and type localhost:8888/wp-admin
    • Follow the wizard
    • When asked for enter Database name, username, password, Host
    • By default username and password both are ‘root
    • Leave the Table prefix as it is and click Submit
    • Next click on Run Installation
    • Give a name, username-password and email-id for your blog
    • Click on Install wordpress. Success!
    • Now when you login, you should be able to see Admin console
Congrats!! You are up and running 
wordpress instance locally

*Alternatively you can also set the path from which MAMP has to serve. Launch MAMP – Go to Preferences – Web Server tab – Change the Document Root folder.

Where to go from here?

I am yet to do this, but definitely next step is to design your website and customize your wordpress installation. Here is a 7 video series on how to build a wordpress site

Now explore installing themes, creating a couple of themes and plugins. Along with creating them it will be interesting to understand how everything fits. I have just installed WP on my system and yet to explore all these.

This is where I learnt how to install WordPress locally.


Protocol oriented Programming (PoP)

This post is a part of my blogpost series while learning Swift and Programming paradigms. First part on Functional Programming can be found here.

Protocol oriented programming (POP) can be said as as – a way to adhere the “Program to interface not to implement” principle – which is one of the basic design principles of software development. Structure your code such that you define interfaces first then make the classes implement it. Define interfaces using protocols and then make classes implement them. POP is just another technical term for the interface programming in Swift programming language.

Yes! There are additional advantages of POP in swift using “Extensions” along with protocols in Swift.

Let us discuss this with a classic example – Shapes and its classes.

Any shape has area. Every shape needs to be drawn on some canvas. Typically an average programmer thinks:

  • Let’s have a base class named Shape.
  • Let’s derive all other concrete classes from Shape class.

The first and foremost disadvantage of this solution is all concrete class inherits everything from base class whether its needed or not. Along with that multiple inheritance is not possible and moreover its a bad way.

In a practical world as the product grows its code grows and there will be a lot of overhead built over a period of time.

Here comes Protocol Oriented Programming – creating interfaces

This is link to Xcode playground @ github – giving a typical example of POP. Please go through the code before proceeding to understand the advantages.
Some plus points of POP :

  • No overhead of base class.
  • Protocol extensions are a great way to give default implementation.
  • Classes can conform to multiple protocols also use their default implementations without overhead of inheritance.
  • Restrict access ONLY to specific functionalities of an object.
  • Protocols can be conformed by structures & enumerations in Swift. Class-Only protocols can also be defined
    [protocol TheClassOnlyProtocol: class { ... }]


  • Protocols can be used as a type for variables, which is more dynamic than declaring variables with concrete classes.
  • Delegation works as it used to in Objective-C.
  • Protocols can be used in Collection types
  • A Protocol can inherit from multiple other protocols (multiple inheritance)

This is my understanding of POP. Please do share your comments below.

Hope you found this post useful to some extent.

What is Functional Programming?

For quite sometime now I am on a new programming language from Apple – Swift. Apart from the hype Swift got there are multiple programming paradigms that I got introduced to – Functional Programming (FP), Protocol oriented programming (PoP).

I was little curious as I knew what functions are and what protocols are used for especially in objective-C, and my mind asked me few questions –

  • What are Functional Programming and Protocol oriented programming?
  • Is swift a Functional Programming language or a Protocol oriented programming language?
  • Is it mandatory to learn in Functional Programming or Protocol oriented programming to code in Swift?
  • What is the right way?

Browsing through some websites and reading few books, this is what I understand. In this post I will be sharing my thoughts & understanding on FP and a subsequent post on PoP.

Q: What is Functional Programming? Answer: (In non-developer’s term) Functional Programming is a way of how you code your solution, it’s a philosophy, it’s not related to any specific programming language.

Technical Answer: Functional programming is a way of programming where focus is on designing functions and their interactions rather than on data unlike Object Oriented Programming(OOP) where focus in on designing classes around data.

A functional programming language supports and encourages programming without side-effects. FP is a way in which you code only pure functions with all objects used in the function are passed as input parameters and all results are defined as output/return objects. In here, Functions are always pure and deterministic.

Now, what are pure functions? Answer: Functions that returns same value for given set of input values at any given point in time. These functions never modify the input values, never access, consume or modify anything outside of its scope.

Technical Answer: The result cannot depend on any hidden objects/values/state that change over a period of time. The function, In the process of execution, cannot cause any semantically observable side effects, like mutation of mutable objects or state change of any other objects.
Following holds true for FP:

  • In FP the focus is on how you design functions rather than modeling the data.
  • In FP utmost preference is given to immutability. FP hates mutating data.
  • In FP results are always same for same values supplied.
  • Functions in FP does not change any values supplied to it, neither change values outside of scope. Input parameters are only consumed but not modified.
  • In FP like Swift and Scala results are most of the time return in containers/optionals. (Yes, I dug into Scala programming language concept to understand few concepts of FP. Optionals in Swift are ‘inspired’ from Monads from Scala 😀 )

Advantages of Functional Programming:

  1. You definitely know what functions do and what they return. No side-effects.
  2. You need not worry much about wrapping data into threads, mutex and locks.
  3. Helps in writing lots of Unit test cases, increasing the code coverage.
  4. Modules can be isolated and independent from each other.
  5. Crash free: Functions return values wrapped in containers [Swift, Scala]

Keeping in mind all of this 2 questions raise in mind:

  1. Can we adopt functional programming in Swift? Yes, Definitely!
  2. Can we build iOS Apps in Swift completely with FP philosophy? Partially Yes. Why? Given my experience with the MV-X (MVC, MVVM, etc.,) patterns used in iOS app development access object properties and mutating datasources somewhere in the code is a must and cannot be avoided. So it is up to a developer to use their creativity to design functions or some modules in an app which adhere completely to FP.

I am new to FP and still experimenting with it, trying to understand it still more deeply. I also thought of adding few code snippets in this post to clearly explain and convert Impure functions into Pure ones, but surely we can discuss this in comments. Let’s discuss in comments section about these interpretations and understandings.

Keep visiting this blog for more programming stuff. Next post on Protocol oriented Programming.

Referred links which helped me understand:

Design Patterns & Principles

This is a part of a blogpost series listing the design principles and pattern definitions.
The Strategy Pattern
– defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets algorithm vary independently from clients that use it.

Following are few principles adhered in this pattern

  • Identify the aspect of your application that vary and separate them from what stays same
  • Program to interface not to an implementation
  • Favor composition over inheritance

The example code for strategy pattern in Swift is available at my github repo.

courtesy: Head First Design Patterns