Tag: PHP

  • The difference "" vs null vs 0

    The difference "" vs null vs 0

    Recently as I was conversing with my young friend, he looked at some of my code and wondered why I was using a zero or null or empty string (“” or ‘ ‘ ) instead of using one wherever I wanted.
    Programming is an interesting though weird or confusing discipline, especially to the novice things don’t mean a lot because most novices concentrate on the output than the efficiency and effectiveness of the output. For the mature programmers optimization is key, after all at the end of the day a user wants something working but requires less attention than something erroneous and slow.
    So let’s get to it. How does null, empty string and zero differ?
    Similarities
    First of all the similarity is of the three is that they are all values to variables and mostly used as the initial value of a variable.
    Second the empty string and null will usually output nothing if printed on the screen.
    Differences
    Differences might be defined differently per programming language.
    For example in Python there is no null but there is None which means the same as null in other programming languages.
    To find out the datatype of None and other values in python use the type( ) function e.g type( None ), will return NoneType data type in python. While in JavaScript we use typeof value to find out the Data type of a value stored in a variable. i.e. console.log( typeof null ) will return object as the data type of null.
    PHP 4+ we use gettype( ) function to find out the datatype of the value stored in the variable. For example gettype( null ) will return for NULL.
    If you are a JavaScript novice it’s good to pay much attention to null values since they are of data type object. For example find out how object data types are treated in JavaScript before you hit a nail in your foot.
     
    Almost all programming languages “” or ” is treated as a string and it occupies the space in memory of the size that is occupied by a string or char datatype. In fact in JavaScript if a value starts with ” even if it’s proceeded by a number or decimal it will be type cast to a string so that the resulting value will of data type string.
    So be careful initializing variables with ” especially if they will be used in mathematical expressions.
    In Java, Python and PHP 0 is treated as an integer whereas it’s treated as a number in JavaScript because in JavaScript integers and floats are number data types. I know most people might be wondering why not a Boolean?
    Though 0 or 1 might represent false/true they are not treated boolean data types.

    Why care?

    It’s always good to code what a programmer and fellow programmers understand to avoid spending time in refactoring than improving functionality and optimization.
    It’s also important to ship a software which will give more predictable results than not to avoid the users plucking hair out of their heads, assuming they’re wrong yet it’s the programmer is the calprit.
    DataTypes determine how big your program will be and how it nay handle memory, avoid confusing by planing to code rightfully from the beginning.
    Note: 
    This tutorial assumes you have some programming knowledge and some level of practice with the one or more of the programming languages cited in the tutorial.
    The tutorial is dedicated to Were Calvin a Ugandan African motion graphics designer and emerging front-end developer practicing at Gagawala Graphics limited.

  • The untold story, shortly fast backward!

    The untold story, shortly fast backward!

    If I remember very well, fast backward in 2008 – 2009, I started teaching myself HTML, JavaScript and PHP. But the inspiration was always developed from the PowerPoint slides I often designed, which sparked my interest in Photoshop.
    Kaweesi Mark used to help jot everything to paper while copying from the webpage in the internet cafe. I was the research genius sitting right there before the computer screen. I couldn’t do it all by myself since we used to foot UGX.500/= for 20mins yet getting that 500/= was kissing the gates of hell. Maybe it’s not hell, but me stealing Aunt’s money was hell. It required courage. Anyway let me leave that story for another day. Do you remember those times bro?
    Just a quick one, if we didn’t collect scrap, if we didn’t play soccer, if we didn’t sneak to watch soccer without paying, if we didn’t sneak in the cinema halls, what if we didn’t, would we be where we are?
    I wish the people reading this are those who admire where I am/we are today, but didn’t actually see us during those days. Many wouldn’t want us closer. I take heart, and I encourage you to persevere. You will achieve everything because you can.
    Cutting short a long story, amidst all the complications and confusion in different software, here and there; what always kept me amazed was clicking on something and it responded somehow. Why don’t I do this?
    From PowerPoint slides (with clip Art) to HTML. Even now I can’t develop a website from scratch without having to sketch on paper, then get to Adobe illustrator/Photoshop mock up the visual representation and then break down into HTML code.
    For whatever it is, one has to go through some sort of fine(creative) Art to lay a foundation for the science of web design.
    You are lucky today, we have CMS so there is no need to grasp code unless you want to be a web developer, a UX specialist, a mobile app developer, a desktop app developer or a programmer scientist.
    You can even become a superb CMS web designer by attending a 12 days practical class. It’s organised by myself and it will be at Aponye Mall, Block B. NBK-Cleaning Kings International‘s offices. My aim is to take you straight from where you are to a superb CMS specialist. The cost is UGX 300K call me on 0704255401.
  • How did I make it to the CMS SUMMIT 16 in Kampala.

    How did I make it to the CMS SUMMIT 16 in Kampala.

    First things first, so let’s get somethings out of the way, CMS is an acronym to mean Content Management System. Examples of CMSes are WordPress(most pupolar), Joomla (Youngest of the giants released in 2005) and Drupal(Oldest not only CMS but a great CMF too).

    How it started in brief.

    In 2006, I started playing around with HTML and Javascript drawing inspiration from movies and video games. Times were tough and I didn’t get to do anything useful for over a year before I was attracted by PHP and started developing simple web based applications.
    Sooner than later, I met someone who wanted a website designed for his start up tourism business.  On landing this job, I was so excited. But it was such a challenge after-wards, a challenge worth taking though. In fact through determination but not prowess, I was able to deliver the project in a few months.
    Developed a couple more web apps in plain HTML, CSS and PHP before I was introduced to Joomla 1.5. I admit, it was a life saver by then, because everything came already engineered. No need to write any piece of code but you could have a website up in a day.
    In 2014, someone else recommended I try out WordPress too. But I was like why? The answer simple, it eases life. From then on, I have never looked anywhere else.

    The first word about CMS Africa summit.

    In most cases, we first hear about things from friends, the people who care. And for me it was none other than Job Thomas from South Africa. A friend I met on twitter after searching for WordPress enthusiasts.
    Even without knowing me in real life, he was welcoming, free and open-minded, ready to contribute knowledge in anyway, he can. I remember disturbing him with a couple of coding related questions, but he pointed me to WordPress forums since he wasn’t a coder, he thought things would be easily solved, if I submitted to forums.
    We conversed for several days then weeks before he introduced me to CMS Africa Summit. CMS Africa summit 16, is a gathering of coders, web enthusiasts, mobile app developers, students of all professions, educators, bloggers, & entrepreneurs etc. Interestingly, it’s coming to my city – Kampala. That means no need to pay air ticket bills. It will bring together 30 keynote speakers and several sponsors. Additionally there would be a 48 hours hackthon.
    Sounds interesting so I registered on the website for a 2 day ticket.

    Day 1. Highly motivated.

    It’s in the wee hours of the morning of 1st-April, 2016, I have my back pack ready excited to attend a web summit for the first time in my life.
    Together with my friend @MutebiIvanJunior – a social media student and successful practitioner, we get on the road, grab a public 14 passenger van on the way to the heart of Kampala; commonly known as Town. All is good, though we are nervous whether we get there in time. You know the tickets have the dates but not the time.
    As we get to town, the clouds are changing from sky blue to smoke gray, things look okay as we are optimistic nothing will stumble. After all, it’s been months of total hotness without any single drop of it.
    It’s now about 7:30am, and we are already in Town for the second taxi to Luzira, we even have to be faster because we don’t know the kickoff hour.  Thus the aim is to get there as early as possible, unless we could miss out something.
    Soon after 25 minutes, we are in Gems Cambridge International school jurisdiction – Luzira town. Before we go head to head with the gifts of mother nature to the farmers.
    Before 9:00am, we are at check point, security confirming we are not carrying anything dangerous. And we are ready to join the audience!
     

Verified by MonsterInsights