Abstraction in WordPress

I listened about the ADTs in my college last semester in subject JAVA. What I know about it is like “An abstract data type is a collection of data and operations that work on that data.” just this Definition. I don’t think any of the student thought about this topic and researched about it. Because it is not a major topic for exams. I also do not know what it is, while reading the Code Complete 2” in the chapter 6 it is all about the ADTs. It is about how programmers create classes with loosely related functions in it, loosely connected data. This type of classes are just easy to create but hard to keep up in future.

In the book there is an example of changing a particular font size from point to pixel and changing it to bold  by creating a particular ADT for that having all the class that can manipulate all the data and can interact like the real world. As I am working on the WordPress so in my example there is a WordPress feature  that have the manipulating function so I can relate with them.

Last time when I am working on the custom posts type creation for a particular post type I came across with the loop of WordPress that have many functions you can use. You just have to think what you want in the code if you need the Title of the post here is the function “get_the_title()”, If you want permalink to add with the an anchor tag just type “get_permalink()”.

The loop is an ADT but if the classes have functions like this then I am sure everyone love to use that module and love to work with and what I read about the Abstraction data types is the same about the abstraction that I am not taking the links or title from the database directly I’m just going through a function and retrieving the data.

If we look at the function get_title() what it explains that it will return the title of the current post and yeah it does it. In WordPress if you are a newbie like me and you are thinking that how you gonna remember the names of the classes/functions so I bet you it is easier to remember the name of functions.

Creating Features in WordPress

Work On The Authentication Plugin

WordPress powers more than 24% of the web  a figure that rises every day. Everything from simple websites, to blogs, to complex portals and enterprise websites, and even applications, are built with WordPress. WordPress is an easy to use framework have simplicity for the users.

I am still exploring the features that WordPress can do. In WordPress there is a feature to add plugins that can increase the features of the WordPress.
In my project at ColoredCow I was asked to create some functionality that can Authenticate users via Google so that we can get access to the Admin Panel by our google ids of that company. Are you thinking that why a firm/company needs the google login system and not using the WordPress’s inbuilt login system. 

What if we use a SSO(Single Sign on) system for the users. It is convenient to the users and employees to log in to the website admin panel.  The idea behind this is to create an automation system for creating new users. A new Employee joined the Company he have the Google Id of that firm so he can get access to the Admin Panel. And there is no need create a new user manually. Like in WordPress Login System we have to go to the users and add a new user. Unlike in our system if you have Companies google id you can access the admin panel.  

In the above discussion a new plugin comes up that is Role Defining plugin. If a new user is login and can access the Admin Panel what features he can access and what type of role is given to him. As the inbuilt roles in WordPress are not good enough for a company so we have to create a new plugin for just to define the roles.In these Plugins the main thing is that to provide the convenience to the user. So that they can get access to Admin Panel via their google IDs.

Work On The Authentication Plugin
Work On The Authentication Plugin

Above is a screenshot of my work on the Authentication Plugin. By this we can Sign in with Google.

First, solve problem Then, write code

At starting of my developing journey when I used to code the HTML and CSS and create some static pages that look awesome (if you don’t compare them with other online websites). I used to experiment on the divisions and the architecture first without applying any style on it so that I just simply add the classes and id’s to it, it is like creating a frame that is just without any style just a normal frame.

So that I can create as many designs from it by just changing or adding the color in the class that I assigned to it. So that I can change the pages by only changing the CSS file. In the Tech Fest of my college “Kaivalya” I worked on my very first project for web. The task is just to make a front end for the website for the college Computer Science Club after making the front end you have to make a backend for it.

When I first see that task I was thinking about how I start building the website. So i just searched many of the websites and choose a website that is very simple in design. At that time I did not know any software principles and the designing aspects. I see the websites and if I like a feature so I added it to my website.

Without proper planning and design I created that website because it is a small project and if there any problem occur I can recreate it from scratch also, but what if I am going to work on bigger project and use this type of approach that I used to create my website then what’s gonna happen. Then the website is not manageable one of the example that when I am working on the WordPress theme creation for the first time I faced the problem in the sidebar that every time I change a bit CSS of main content the sidebar get exploded.

It is because I did not settled the width of the divisions of main and sidebar content but then I first created a diagram for that and defined that how much part of the screen it is going to be covered by the different containers. The theme has many other flaws but it is just the starting of my WordPress Journey.

Design is the creation of the plan, the solution to the problem, that it be like how one will see the problem in his aspect, everyone have a different solution. We just have to think in every direction. I am reading a book named Code Complete and in it an example is given with a topic “Design Is a Wicked Problem” it is about design of a Bridge named “Tacoma Narrows bridge“.

At that time when the Bridge was built the main focus of engineers is to give it a strength that it is strong enough to support the load. But due to the Aeroelastic Flutter of the wind and the bridge is not ready to handle the air of speed 68km/h so it get collapsed. A nearby photographer recorded a footage of it when this happened. This footage is still shown to engineering, architecture, and physics students as a cautionary tale.

But what is the moral of the story. In my opinion the moral is about the seeing the problem in every direction and generate your own test cases as if they were aware of the Aerodynamics thing they will make a design that the bridge can withstand in the high-speed of air also. And it be like Trial and error method that they created a bridge and it get collapsed only in 4 months of creation so that they find out about the aerodynamics of the bridge and created a new design for the next bridges so that it will never happen in future.

We have to learn from our previous errors and have to try new things. Cause design is not an algorithmic process it is heuristic in nature. One of the problem like this occurred with us that we three Nitin, Dhiraj and Me are working on a plugin for Hiring System for ColoredCow. The problem is that when we are said to create the plugin that displays the Vacancies available we think about in a way that it will be like a widget for the site that will show the vacancies in a carousel way.

So we created a widget but then after delivery we find out that what they want is other than this Widget thing they just wants a shortcode method that wherever they want to put that carousel they just have to add the shortcode. This is not a big deal but it will be like an example of not seeing the problem in different way or may be not seeing in the clients way of using the Software. Now we added that feature too.

For our college group for Web Development we created a task that is just to check the designing skills of the students. It is more like an experiment that how they react on the task and derive their answers.

The task is to create a website for a firm with a basic functionalities eg. Home page, About Page etc.. Everyone come up with different designs and some of them added the exact pages that we mentioned some used their creativity and added other features and pages to the website. It relates me to the topic of Managing complexity in the “Code Complete” that the webpages we mentioned are the basic requirement and are essential for a website. But the other accidental features are also demanded by any firm that he does not mention like in above example client may be think that we add the event and notice bar our self or anything.

It is depends on person to person how they design and the time factor or may be other factors also. First Solving the problem then starting the design phase will help more in coding phase then directly starting the code without the plan or Design. As the John Johnson said

First, solve the problem. Then, write the code.

Why to start from Basics

When I started working on the project we are given started the project from creating the Repository on GIT, installed the WordPress and pushed all the data in directory of WordPress to the repository (including the config. file with the passwords of database). Then in our code review, we find out that we are wrong, we just uploaded all the core files and with passwords along with it. And then I created a new repository and now I added a .Gitignore to ignore some files of WordPress like config file so I thought now I am in the right direction.
As I didn’t search about the basic that way to add WordPress git integration and how the only public file can be there in repository So I am just in the wrong direction again. Now we discussed about it with Vaibhav that how the Integration works then he told us that why we need the core files on the GIT they can be configured by the another contributor so why? then we got to know about the Composer that this is the thing we are missing we have to create a composer installation file that can configure all the WordPress files and we need to take care of just the public ones.

We can install WordPress on the remote server by composer. This is happening because we don’t know the basics. If we know why to integrate the WordPress and the How so that our details not be shared like our first repository. And next on we added PHP codes on the files to get access to the files, etc. in WordPress😛 ) means if we are working in the WordPress then why we used the PHP because we don’t know what the basic approach is to have there in a random project. So start from basics to get into it.

Building the Core

Great minds have tended to create and they are creative and curious about what’s happening. The thing that I love at ColoredCow that there are lots of people to guide us and love to create the environment that everyone can learn from each other and discuss ideas. In the software industry there is a lot to work and achieve the success. You can make it by two methods anyhow by Jugaad or by applying some principles and doing it in the right way. By Creating the models ideas. If we have a project we are asked that “How you going to achieve that, anyways or applying some principle and starting from the core”.

The “why” and “how” is the question here. I want to relate to the newton’s story that he discovered about the Gravity by falling of an apple. He asked himself the why and which is his idea of exploring. Three types of people can be there(or more maybe) if we discuss it that, the ones who is interested in the personality of the Issac Newton and talk about him or interested in the apple, second one who are discussing about his discovery details about gravity, the third one discuss on the “why” once again as the Einstein did on theory of relativity even if the Newton’s theory is accepted globally. Here the “why” is core. The quote

Great minds discuss ideas, average minds discuss events, small minds discuss people.

Work on your basics and make great things happen. As in our first Code Review they told about the core building. Start from the basics and start from asking questions.

Working On Git

WordPress is a famous CMS that based on PHP and MySQL. You can create blogs(just like this one) and websites for your own and yeah its free to use open source so you can install on your own server and make any changes to it. If you are working on a small project and only you are on the team so you can check all the code on your own Machine and put the code on the server.

But if you are working in a team and have to work on different features and may be your codes can be overlap then what you are going to do. Here we need GIT the very famous Version Control System that can track our codes and earlier versions. If you are working on different features you can create branches as well.

The Documentation on Git is the best place you can learn about it.On working on my very first live project in ColoredCow I am working in a team so that I have to learn GIT first to work smartly. So I just googled it out and remembered some commands and learn how to pull and push the code. KD gave a good explanation on GIT last day. And he said to set some rules to use GIT because sometimes it just overwritten our code with another teammate who just edited the code.

The Rules are :

  • Pull the Code
  • Push your Code
  • Write Code
  • Commit the New
  • Pull
  • Push

These steps are a healthy practice for a developer.