<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[The Rhapsody]]></title><description><![CDATA[A developer's shenanigans.]]></description><link>https://rhapsody.azurewebsites.net/</link><generator>Ghost 0.7</generator><lastBuildDate>Tue, 05 May 2026 11:50:59 GMT</lastBuildDate><atom:link href="https://rhapsody.azurewebsites.net/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Consuming RESTful Web Services with Spring Boot - Tutorial]]></title><description><![CDATA[Consuming RESTful Web Services with Spring Boot]]></description><link>https://rhapsody.azurewebsites.net/2018/08/10/rest-in-spring/</link><guid isPermaLink="false">3ab6b13e-ed43-4109-98f5-dbc2bb428080</guid><category><![CDATA[MVC]]></category><category><![CDATA[Encapsulation]]></category><category><![CDATA[java]]></category><category><![CDATA[MySQL]]></category><category><![CDATA[API]]></category><category><![CDATA[REST]]></category><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Fri, 10 Aug 2018 20:20:00 GMT</pubDate><content:encoded><![CDATA[<p><strong>RESTful</strong> web services are built to work best on the Web. Representational State Transfer (REST) means that when a RESTful API is called, the server will transfer to the client a representation of the state of the requested resource.</p>

<p>In this interactive tutorial, we will build a RESTful API that will be implemented in a simple note-taking application using CRUD methods i.e: create, retrieve, update and deletion of notes. </p>

<p>Let's get our hands dirty..</p>

<p>What we will be using: <br>
1. Spring Boot - this will be our MVC based framework based on Java. <br>
2. MySQL - our relational database system and where our schema will run <br>
3. Postman - for handling our API calls <br>
4. An IDE with the Spring development environment - <br>
Netbeans/STS suite/Eclipse can work.</p>

<p>Spring Boot provides a web tool called <strong>Spring Initializer</strong> to bootstrap an application quickly. Just go to <a href="http://start.spring.io">http://start.spring.io</a> and follow the steps below to generate a new project.</p>

<p>Step 1 : Click Switch to full version on <a href="http://start.spring.io">http://start.spring.io</a> page.</p>

<p>Step 2 : Enter the details as the screenshot below shows:</p>

<p><img src="https://github.com/nelsonkimaiga/sturdy-sniffle/blob/master/images/spring.PNG?raw=true" alt="alt text" title="spring mvc"></p>

<p>Once all the details are entered, click Generate Project to generate and download your project. Spring Initializer will generate the project with the details you have entered and download a zip file with all the project folders.</p>

<p>Next, Unzip the downloaded zip file and import it into your favorite IDE. </p>

<p>A few details on our newly created application -</p>

<ol>
<li>RhapsodyNotesApplication</li>
</ol>

<p>This is the main entry point of our Spring Boot application.</p>

<pre><code>package com.example.rhapsodynotes;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
public class RhapsodyNotesApplication {

public static void main(String[] args) {
    SpringApplication.run(EasyNotesApplication.class, args);
}
}
</code></pre>

<p>It contains a simple annotation called <code>@SpringBootApplication</code> which is a combination of the following more specific spring annotations: </p>

<p>@EnableAutoConfiguration: This annotation tells Spring to automatically configure your application based on the dependencies that you have added in the pom.xml file.</p>

<p>For example, If spring-data-jpa or spring-jdbc is in the classpath, then it automatically tries to configure a DataSource by reading the database properties from application.properties file.</p>

<p>The main() method calls Spring Boot’s SpringApplication.run() method to launch the application.</p>

<ol>
<li>resources/</li>
</ol>

<p>This directory, as the name suggests, is dedicated to all the static resources, templates and property files.</p>

<p>resources/static - contains static resources such as css, js and images.</p>

<p>resources/templates - contains server-side templates which are rendered by Spring.</p>

<p>resources/application.properties - This file is very important. It contains application-wide properties. Spring reads the properties defined in this file to configure your application. You can define server’s default port, server’s context path, database URLs etc, in this file.</p>

<p>You can refer this file for common application properties used in Spring Boot.</p>

<ol>
<li>pom.xml - contains all the project dependencies</li>
</ol>

<p>Configuring MySQL Database <br>
As I pointed out earlier, Spring Boot tries to auto-configure a DataSource if spring-data-jpa is in the classpath by reading the database configuration from application.properties file.</p>

<p>Open application.properties file and add the following properties to it.</p>

<pre><code>## Spring DATASOURCE (DataSourceAutoConfiguration &amp; DataSourceProperties)
spring.datasource.url = 
jdbc:mysql://localhost:3306/notes_app?useSSL=false
spring.datasource.username = root
spring.datasource.password = 303seminarian

## Hibernate Properties
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
</code></pre>

<p>You will need to create a database named notes_app in MySQL, and change the spring.datasource.username &amp; spring.datasource.password properties as per your MySQL installation. </p>

<p>In the above properties file, the last two properties are for hibernate. Spring Boot uses Hibernate as the default JPA implementation.</p>

<p>The property spring.jpa.hibernate.ddl-auto is used for database initialization. I’ve used the value “update” for this property.</p>

<p>It does two things -</p>

<p>When you define a domain model, a table will automatically be created in the database and the fields of the domain model will be mapped to the corresponding columns in the table.</p>

<p>Any change to the domain model will also trigger an update to the table. For example, If you change the name or type of a field, or add another field to the model, then all these changes will be reflected in the mapped table as well.</p>

<p>Using update for spring.jpa.hibernate.ddl-auto property is fine for development. But, For production, You should keep the value of this property to “validate”, and use a database migration tool like Flyway for managing changes in the database schema.</p>

<p><strong>Creating the Note model</strong></p>

<p>Let’s now create the Note model. Our Note model has following fields -</p>

<p>id: Primary Key with Auto Increment. <br>
title: The title of the Note. (NOT NULL field) <br>
content: Note’s content. (NOT NULL field) <br>
createdAt: Time at which the Note was created. <br>
updatedAt: Time at which the Note was updated.</p>

<p>Now, let’s see how we can model this in Spring. Create a new package called model inside <code>com.example.rhapsodynotes</code> and add a class named <code>Note.java</code> with following contents -</p>

<pre><code class="language-/*"> * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example.rhaposdynotes.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;  
import java.io.Serializable;  
import org.springframework.data.annotation.CreatedDate;  
import org.springframework.data.annotation.LastModifiedDate;  
import org.springframework.data.jpa.domain.support.AuditingEntityListener;  
import javax.persistence.*;  
import javax.validation.constraints.NotBlank;  
import java.util.Date;  
/**
 *
 * @author Kimaiga
 */

@Entity
@Table(name = "notes")
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = {"createdAt", "updatedAt"}, 
        allowGetters = true)
public class Note implements Serializable {  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank
    private String title;

    @NotBlank
    private String content;

    @Column(nullable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @CreatedDate
    private Date createdAt;

    @Column(nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @LastModifiedDate
    private Date updatedAt;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

}
</code></pre>

<p><strong>Enable JPA in the main application.</strong></p>

<p>Open <code>RhapsodyNotesApplication.java</code> and add <code>@EnableJpaAuditing</code> annotation.</p>

<pre><code class="language-/*"> * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example.rhapsodynotes.repository;

import com.example.rhapsodynotes.model.Note;  
import org.springframework.data.jpa.repository.JpaRepository;

/**
 *
 * @author Kimaiga
 */
public interface NoteRepository extends JpaRepository&lt;Note, Long&gt; {

}
</code></pre>

<p><strong>Creating <code>NoteRepository</code> to access data from the database</strong></p>

<p>The next thing we’re going to do is create a repository to access Note’s data from the database.</p>

<p>Spring Data JPA has got us covered here. It comes with a <code>JpaRepository</code> interface which defines methods for all the CRUD operations on the entity, and a default implementation of <code>JpaRepository</code> called <code>SimpleJpaRepository</code>.</p>

<p>Still sailing! Let’s create the repository now. First, Create a new package called repository inside the base package <code>com.example.rhapsodynotes</code>. Then, create an interface called <code>NoteRepository</code> and extend it from <code>JpaRepository</code>:</p>

<pre><code>/** To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.*/

package com.example.rhapsodynotes.repository;

import com.example.rhapsodynotes.model.Note;
import org.springframework.data.jpa.repository.JpaRepository;

/**
 *
 * @author Kimaiga
 */
 public interface NoteRepository extends JpaRepository&lt;Note, Long&gt; {

}
</code></pre>

<p>That is all you have to do in the repository layer. You will now be able to use <code>JpaRepository</code>’s methods like <code>save()</code>, <code>findOne()</code>, <code>findAll()</code>, <code>count()</code>, <code>delete()</code> etc.</p>

<p>You don’t need to implement these methods. They are already implemented by Spring Data JPA’s <code>SimpleJpaRepository</code>. This implementation is plugged in by Spring automatically at runtime.</p>

<p><strong>Exception Handling</strong></p>

<p>We’ll define the Rest APIs for creating, retrieving, updating, and deleting a Note in the next section.</p>

<p>The APIs will throw a <code>ResourceNotFoundException</code> whenever a Note with a given id is not found in the database.</p>

<p>Following is the definition of <code>ResourceNotFoundException</code>. (I’ve created a package named exception inside com.example.rhapsodyotes to store this exception class):</p>

<pre><code>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example.rhapsodynotes.exception;


import org.springframework.http.HttpStatus;  
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 *
 * @author Kimaiga
 */

@ResponseStatus(value = HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends RuntimeException {  
    private String resourceName;
    private String fieldName;
    private Object fieldValue;

    /**
     * Creates a new instance of &lt;code&gt;ResourceNotFoundException&lt;/code&gt; without
     * detail message.
     */
    public ResourceNotFoundException( String resourceName, String fieldName, Object fieldValue) {
        super(String.format("%s not found with %s : '%s'", resourceName, fieldName, fieldValue));
        this.resourceName = resourceName;
        this.fieldName = fieldName;
        this.fieldValue = fieldValue;
    }
    /**
     * Constructs an instance of &lt;code&gt;ResourceNotFoundException&lt;/code&gt; with the
     * specified detail message.
     *
     * @param msg the detail message.
     */

    public String getResourceName(){
        return resourceName;
    }

    public String getFieldName() {
        return fieldName;
    }

    public Object getFieldValue() {
        return fieldValue;
    }

    public ResourceNotFoundException(String msg) {
        super(msg);
    }
}
</code></pre>

<p>Notice the use of <code>@ResponseStatus</code> annotation in the above exception class. This will cause Spring boot to respond with the specified HTTP status code whenever this exception is thrown from your controller.</p>

<p><strong>Creating our NoteController</strong></p>

<p>We’ll now create the REST APIs for creating, retrieving, updating and deleting a Note.</p>

<p>First, create a new package controller inside com.example.rhapsodynotes. Then, create a new class <code>NoteController.java</code> with the following code snippet -</p>

<pre><code>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example.easynotes.controller;

import org.springframework.stereotype.Controller;  
import org.springframework.ui.Model;  
import org.springframework.web.bind.annotation.RequestMapping;  
import com.example.easynotes.exception.ResourceNotFoundException;  
import com.example.rhapsodynotes.model.Note;  
import com.example.rhapsody.repository.NoteRepository;  
import org.springframework.beans.factory.annotation.Autowired;  
import org.springframework.http.ResponseEntity;  
import org.springframework.web.bind.annotation.*;  
import javax.validation.Valid;  
import java.util.List;

/**
 *
 * @author Kimaiga
 */
@RestController
@RequestMapping("/api")
public class NoteController {  
    @Autowired
    NoteRepository noteRepository;

    // Get All Notes
    @GetMapping("/notes")
    public List&lt;Note&gt; getAllNotes() {
        return noteRepository.findAll();
    }

    // Create a new Note
    @PostMapping("/notes")
    public Note createNote(@Valid @RequestBody Note note) {
        return noteRepository.save(note);
    }
    // Get a Single Note
    @GetMapping("/notes/{id}")
    public Note getNoteById(@PathVariable(value = "id") Long noteId) {
        return noteRepository.findById(noteId).orElseThrow(() -&gt; new ResourceNotFoundException("Note", "id", noteId));
    }

    // Update a Note
    @PutMapping("/notes/{id}")
    public Note updateNote(@PathVariable(value = "id") Long noteId, @Valid @RequestBody Note noteDetails) {

    Note note = noteRepository.findById(noteId).orElseThrow(() -&gt; new ResourceNotFoundException("Note", "id", noteId));

    note.setTitle(noteDetails.getTitle());
    note.setContent(noteDetails.getContent());

    Note updatedNote = noteRepository.save(note);
    return updatedNote;
}

    // Delete a Note
    @DeleteMapping("/notes/{id}")
    public ResponseEntity&lt;?&gt; deleteNote(@PathVariable(value = "id") Long noteId) {
    Note note = noteRepository.findById(noteId).orElseThrow(() -&gt; new ResourceNotFoundException("Note", "id", noteId));

    noteRepository.delete(note);

    return ResponseEntity.ok().build();
}

}
</code></pre>

<p><code>@RestController</code> annotation is a combination of Spring’s <code>@Controller</code> and <code>@ResponseBody</code> annotations.</p>

<p>The <code>@Controller</code> annotation is used to define a controller and the <code>@ResponseBody</code> annotation is used to indicate that the return value of a method should be used as the response body of the request.</p>

<p><strong>@RequestMapping("/api")</strong> declares that the url for all the apis in this controller will start with /api.</p>

<p><strong>Testing the APIs</strong></p>

<p>We’ve successfully built all the apis for our application. Let’s now run the app and test the apis.</p>

<p>The application will start at Spring Boot’s default port 8080. It’s time to test our apis using postman. Add the URL: <code>http://localhost:8080/easy-notes/api/notes/</code> on your postman URL bar and select a HTTP method to make a request. Based on the API calls, you should be able to get various response codes. Remember the input type to use is in JSON format.</p>

<p>We've successfully built a Restful CRUD API using Spring Boot, Mysql, Jpa and Hibernate.</p>

<p>You can find the <a href="https://github.com/nelsonkimaiga/sturdy-sniffle">source code</a> for this tutorial on my github repository. Feel free to clone the repository and build upon it.</p>]]></content:encoded></item><item><title><![CDATA[The concept of abstraction]]></title><description><![CDATA[<p>Abstraction is a key concept in the domain of Object-Oriented programming as well as the understanding of data structures and algorithms. The dictionary meaning of <strong><em>Abstract</em></strong> refers to something that exists only in idea but not in physical or realistic existence. It is from this basic understanding that I'll attempt</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/07/09/the-concept-of-abstraction-2/</link><guid isPermaLink="false">9d18594d-d099-44cb-bedc-e90d327b988c</guid><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Sat, 09 Jul 2016 14:17:41 GMT</pubDate><content:encoded><![CDATA[<p>Abstraction is a key concept in the domain of Object-Oriented programming as well as the understanding of data structures and algorithms. The dictionary meaning of <strong><em>Abstract</em></strong> refers to something that exists only in idea but not in physical or realistic existence. It is from this basic understanding that I'll attempt to explain the concept of abstraction from a real-life scenario. </p>

<p>Abstraction is a process where we show <strong><em>only relevant</em></strong> data and <strong><em>hide</em></strong> unnecessary details of an object from the user. For example, Consider the remote control of a TV, you as the user only know which key to press for what function. You will not know what happens inside when you press whichever button. This is the kind of scenario that happens in Java. Abstraction is achieved with the help of interfaces. In this case, the remote control of the TV is an interface. It these interfaces that expose only methods to end users with a view to reducing complexity and increasing efficiency of using the object.</p>

<p>We can enhance the internal implementation without effecting outside world. Abstraction provides security. A class contains lot of data and the user does not need the entire data. The advantage of abstraction is that every user will get their own view of the data according to their requirements and will not get confused with unnecessary data.</p>

<p>When we hide unnecessary details of an object from a user, this is described as <strong><em>data hiding</em></strong>, which is a process of keeping out internal data safe from un-authorized access. This means no one can access our internal data directly.</p>

<p>In my last blog <a href="http://rhapsody.azurewebsites.net/2016/07/04/an-implementation-of-getters-and-setters-methods-in-java/">post</a>, I demonstrated how we can achieve data hiding programatically by declaring data members as private, so that an outside person (or object) can access our data through public methods using getters and setters.</p>

<blockquote>
  <p><strong><em>Real-life example</em></strong></p>
</blockquote>

<p>Let's say for instance you are a member of a bank in which many other people's accounts are there. There is some banking software which has been implemented in such a way that the <strong><em>bank balance</em></strong> variable is defined as a <strong><em>public</em></strong> variable. This means that if you are having an account in this bank, then your account balance is somehow known to the public, so any one can know your account balance. Ideally, no one would like this because one's bank balance is a private piece of info.</p>

<p>So in order to make your account safe such banking software declares the balance variable as a <strong><em>private</em></strong> variable so that anyone who wants to access this private data can only do so through methods defined inside that class, and this method will be probably asking the account holder to input his/her account number, as well as a PIN number for authentication purposes.</p>

<p>So by utilizing the concept of data hiding,security is achieved. This is one of the mechanisms through which <strong><em>encapsulation</em></strong> works.</p>

<p>In summary, encapsulation can be loosely defined as the wrapping up of data into a single unit. Abstraction on the other hand refers to selecting only the necessary details from the given data without compromising on the functionality. Encapsulation allows abstraction since they work hand in hand. Encapsulation itself is a subset of abstraction by hiding what you don't need while abstraction shows you what you need.</p>]]></content:encoded></item><item><title><![CDATA[An implementation of Getters and Setters Methods in Java]]></title><description><![CDATA[<p>Getter and setter emanate from the concept of Encapsulation which a fundamental concept of OOP as discussed in a recent blog post. In ecapsulation, much of the mechanisms is matters data hiding which entails the variables of a class being hidden from other classes, and this particular class being accessed</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/07/04/an-implementation-of-getters-and-setters-methods-in-java/</link><guid isPermaLink="false">d3796617-4355-435f-91c8-c8c22f777a89</guid><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Mon, 04 Jul 2016 15:50:29 GMT</pubDate><content:encoded><![CDATA[<p>Getter and setter emanate from the concept of Encapsulation which a fundamental concept of OOP as discussed in a recent blog post. In ecapsulation, much of the mechanisms is matters data hiding which entails the variables of a class being hidden from other classes, and this particular class being accessed only through the methods of their current class. In a nutshell, getter-setter methods simply mean:</p>

<blockquote>
  <p><strong><em>Look but don't touch</em></strong></p>
</blockquote>

<p>Explaining getter-setter concepts to a beginner maybe quite complex especially if they have no initial exposure to OOP o even programming at all. Let's take the example of people having fun in a party. Let's assume these people to be objects. They have personal information which we will call<strong>"attributes"</strong>. Some of this personal information is sensitive and they do not want every body to know. Say for example, someone does not want to reveal their mobile number to the public. Those are pieces of information these objects (or party people) will declare as <strong>"private"</strong> There is some other information they do want to reveal to the public. For example, they may want to reveal their name to their new acquaintances. This is the kind of attributes or pieces of information they could declare as <strong>"public"</strong></p>

<p>Revealing personal attributes as public allows others not only to read the information but also to modify it. And this is the reason our objects would rather protect certain information by declaring it private (So other objects cannot access them directly) and letting others access that information only if they ask through a provided mechanism we will call <strong><em>method</em></strong>. The mechanisms for asking an object to reveal information about itself we may call <strong><em>getter</em></strong>.</p>

<p>Having others ask for their sensitive information through a method instead of letting them access directly their personal info allows objects to respond only when they want (to objects they trust, for example) and allows them to hide information they would rather not reveal.  If one of our party goers have objections to revealing her age, for example, she may choose to lie about it and tell everyone she is 20. Our objects can  let others know their name through a <strong><em>getter</em></strong>.</p>

<p>Some times objects will want others to be able to suggest changes to their own state. One of our objects may, for example, ask others for suggestions as to which color she should die her hair next. For this kind of situations they can declare a <strong><em>setter</em></strong> mechanism through which others can suggest such changes but our objects will still be in control of whether they make those changes or not or whether they will take some other actions triggered by this request. This way our object can decide whether to die her hair green or wait for a better suggestion.</p>

<p>Lets implement this <br>
To achieve this: <br>
* Declare the variables of a class as private.
* Provide public setter and getter methods to modify and view the variables values.</p>

<p>Step 1: <br>
<code>public class GetterSetter{
   private String name;
   private String idNum;
   private int age;
   public int getAge(){
      return age;
   }
   public String getName(){
      return name;
   }
   public String getIdNum(){
      return idNum;
   }
   public void setAge( int newAge){
      age = newAge;
   }
   public void setName(String newName){
      name = newName;
   }
public void setIdNum( String newId){ <br>
      idNum = newId;
   }
}</code></p>

<p>Then we can access the variables of GetterSetter class as follows:</p>

<p><code>public class TestSetter{
public static void main(String args[]){ <br>
      TestSetter testsetter = new TestSetter();
      testsetter.setName("Mary");
      testsetter.setAge(20);
      testsetter.setIdNum("12343MS");
      System.out.print("Name : " + testsetter.getName() + " Age : " + testsetter.getAge());
    }
}</code></p>]]></content:encoded></item><item><title><![CDATA[System Development Methodologies - Part 2]]></title><description><![CDATA[<p>As seen in <a href="http://rhapsody.azurewebsites.net/2016/06/03/system-development-methodologies/">Part 1</a> of this article series, there is sufficient reason to always have a good system development methodology for any project that you are working on. Ideally, what will distinguish you as a good developer from the rest of other bandwagon developers is <strong><em>best practices</em></strong></p>

<p>Additionally, we</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/06/08/system-development-methodologies-part-2/</link><guid isPermaLink="false">43dbc094-2b02-4085-b70f-10128a9214fd</guid><category><![CDATA[objects]]></category><category><![CDATA[methods]]></category><category><![CDATA[methodology]]></category><category><![CDATA[analysis]]></category><category><![CDATA[design]]></category><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Wed, 08 Jun 2016 16:12:16 GMT</pubDate><content:encoded><![CDATA[<p>As seen in <a href="http://rhapsody.azurewebsites.net/2016/06/03/system-development-methodologies/">Part 1</a> of this article series, there is sufficient reason to always have a good system development methodology for any project that you are working on. Ideally, what will distinguish you as a good developer from the rest of other bandwagon developers is <strong><em>best practices</em></strong></p>

<p>Additionally, we went ahead to specify two common types of development methodologies; namely: <strong><em>Object-oriented analysis and design (OOAD)</em></strong> and <strong><em>structure-oriented analysis and design.</em></strong> The former is quite common given it's robust nature as well as the elements of object-orientation and abstraction which are quite an influencing factor for a programmer's work. </p>

<p>This article seeks to break down the differences between the two so as to bring the element of clarity. </p>

<blockquote>
  <p><strong><em>Object Oriented Analysis and Design</em></strong></p>
</blockquote>

<ul>
<li>Uses an incremental methodology.</li>
<li>Has a very low risk</li>
<li>Mainly focused on objects, their names, and their variables.</li>
<li>Mostly suitable for large risky projects with changing user requirements</li>
</ul>

<blockquote>
  <p><strong><em>structure-oriented analysis and design.</em></strong></p>
</blockquote>

<ul>
<li>Uses a methodology based on the software development life cycle.</li>
<li>Focused on processes only.</li>
<li>Mostly suitable for well defined projects with stable user requirements.</li>
</ul>

<p>And there it is. Before settling on either of the two, it is important to architect the system being developed theoretically first, ideate around it such that the choice of methodology would be rational.</p>]]></content:encoded></item><item><title><![CDATA[Algorithm Complexity -The easiest way explained.]]></title><description><![CDATA[<blockquote>
  <p><em>Know Thy Complexities!</em></p>
</blockquote>

<p>In computer science, much of the theoretical elements have their uses and their applications can turn out to be quite practical. In this article, we will come across terminologies such as the 'Big O notation' and algorithm complexity analysis, a concept which many developers as well as</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/06/06/algorithm-complexity-the-easiest-way-explained/</link><guid isPermaLink="false">1238ec85-9f40-475c-993b-bd776b297805</guid><category><![CDATA[data strcutures]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[Big-O notation]]></category><category><![CDATA[time]]></category><category><![CDATA[complexity]]></category><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Mon, 06 Jun 2016 13:40:00 GMT</pubDate><content:encoded><![CDATA[<blockquote>
  <p><em>Know Thy Complexities!</em></p>
</blockquote>

<p>In computer science, much of the theoretical elements have their uses and their applications can turn out to be quite practical. In this article, we will come across terminologies such as the 'Big O notation' and algorithm complexity analysis, a concept which many developers as well as learners find hard to understand, fear, or avoid altogether as useless. <br>
Ideally, Algorithm  complexities are just a way to formally measure how fast a program or algorithm runs, so it really is quite a pragmatic approach to matters programming. In data structures and algorithms, We define complexity as a numerical function <em>T(n)</em> - time versus the input size <em>n</em>.</p>

<p>Here is where the circus begins: <br>
<strong><em>T(n)</em></strong> refers to the maximum amount of time taken on any input of size <strong><em>n</em></strong>. A given algorithm will take different amounts of time on the same inputs depending on such factors as: processor speed; instruction set, disk speed, type of compiler among other factors. The time complexity of algorithms is most commonly expressed using the <strong><em>big O notation</em></strong>. Since Since an algorithm's performance may vary with different types of input data, hence for an algorithm we usually use the <strong><em>worst-case Time complexity</em></strong> of an algorithm because that is the maximum time taken for any input size. </p>

<p>For now, that's all you need to in order familiarize yourself with as far as algorithm terminologies are concerned. Further emphasis will be put into calculating time complexity, using mathematical approaches, a somehow confusing concept which will form the content of my next blog post.  </p>]]></content:encoded></item><item><title><![CDATA[System development Methodologies]]></title><description><![CDATA[<p>Many times, we work on projects without any requisite practices or approach as to how the job should be done. Depending on the language being used as well as the system architecture in question, it is always good practice to have a <strong><em>system development methodology.</em></strong>  </p>

<blockquote>
  <p>A methodology is an algorithm,</p></blockquote>]]></description><link>https://rhapsody.azurewebsites.net/2016/06/03/system-development-methodologies/</link><guid isPermaLink="false">62ddf967-c054-4bf9-b8a1-d2bca7b67e63</guid><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Fri, 03 Jun 2016 06:06:26 GMT</pubDate><content:encoded><![CDATA[<p>Many times, we work on projects without any requisite practices or approach as to how the job should be done. Depending on the language being used as well as the system architecture in question, it is always good practice to have a <strong><em>system development methodology.</em></strong>  </p>

<blockquote>
  <p>A methodology is an algorithm, which includes formulas as well as a set of practices. It does not set out to provide solutions, but rather sets out to create an understanding of which method can be applied to a particular case.</p>
</blockquote>

<p>The preferred methodology for  most projects that are done therefore is through <strong>Object-oriented analysis and design (OOAD)</strong>. Object-oriented analysis and design (OOAD) is a software development approach that analyses a system as a group of interacting objects. Software objects are conceptually similar to real-world objects, they too consist of state and related behavior. Basically, an object exposes its behavior through methods or functions. </p>

<p>The idea behind the selection of this methodology is to facilitate development of system components in a way that they are flexible and can be easily reused. It also facilitates changing of system requirements to improve functionality during the system lifetime. Concepts in the analysis model which is technology independent, are mapped onto implementing classes and interfaces resulting in a model of the solution domain, i.e., a detailed description of how the system is to be built on concrete technologies. <br>
Object-oriented analysis and design enables the standardization of objects which increases design understanding and decreases the risk associated with project development.</p>

<p>Some of the pros of this methodology are: <br>
<strong><em>Maintainability</em></strong>- Object-Oriented programming methods make code more maintainable. Identifying the source of errors becomes easier because objects are self-contained. The principles of good Object-Oriented Programming design contribute to an application’s maintainability.</p>

<p><strong><em>Reusable</em></strong>-Because objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes” (encapsulation).This feature makes it easy to reuse code in systems anywhere it suites.</p>

<p><strong><em>Scalability</em></strong> is the ability of a system, network, or process, to handle growing amount of work in a capable manner or its ability to be enlarged to accommodate that growth. As an object’s interface provides a road-map for reusing the object in new software, it also provides you with all the information you need to replace  the object without affecting other code. This makes it easy to replace old and aging code with faster algorithms and newer technology.</p>

<p>My next post shall give an exclusive breakdown of differences between object-oriented analysis and design and structure-oriented analysis and design.</p>]]></content:encoded></item><item><title><![CDATA[Object-Oriented Programming  in a nutshell-part 2]]></title><description><![CDATA[<p>In the most <a href="http://rhapsody.azurewebsites.net/2016/05/27/object-oriented-programming-in-a-nut-shell/">recent article</a> published on the <a href="http://rhapsody.azurewebsites.net">Rhapsody</a>, the basic concept of Object-orientation with respect to Java was discussed. I also did a preliminary implementation of the OOP concepts using a Java class, a method as well as an object. </p>

<p>Today's article focuses on more Object-Oriented programming concepts with</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/06/01/object-oriented-programming-in-a-nutshell-part-2/</link><guid isPermaLink="false">55da10cb-0cdb-4980-babd-2c4e782824e0</guid><category><![CDATA[java]]></category><category><![CDATA[oop]]></category><category><![CDATA[inheritance]]></category><category><![CDATA[objects]]></category><category><![CDATA[classes]]></category><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Wed, 01 Jun 2016 05:31:22 GMT</pubDate><content:encoded><![CDATA[<p>In the most <a href="http://rhapsody.azurewebsites.net/2016/05/27/object-oriented-programming-in-a-nut-shell/">recent article</a> published on the <a href="http://rhapsody.azurewebsites.net">Rhapsody</a>, the basic concept of Object-orientation with respect to Java was discussed. I also did a preliminary implementation of the OOP concepts using a Java class, a method as well as an object. </p>

<p>Today's article focuses on more Object-Oriented programming concepts with a view to understanding these horror terms: <em>Inheritance</em> and <em>Abstraction</em></p>

<h6 id="abstraction"><strong>Abstraction</strong></h6>

<p>We kick off this interesting series with <em>Abstraction</em>. Literally, abstraction is the tendency to go with ideas rather than events. From an OOP-perspective, abstraction refers to the a process of hiding the implementation details from the user, thus only the functionality will be provided to the user. In other words user will have the information on what the object does instead of how it does it.</p>

<h6 id="inheritance">Inheritance</h6>

<p>Using the most realistic intro to this word, I would simply say that Inheritance is the tendency of classes to inherit commonly used state and behavior from other classes. Doesn't make sense I know right? Ideally, the derived class inherits the states and behaviors from the base class. The derived class is also called subclass and the base class is also known as super-class. The derived class can add its own additional variables and methods. Typical example:  A mountain bike, a road bike all share the characteristics of bicycles i.e: current speed, current pedal layout, current gear. Yet each also defines additional features that make them different: road bikes have drop handlebars; some mountain bikes have an additional chain ring, giving them a lower gear ratio.</p>

<p>In this example, Bicycle now becomes the superclass of MountainBike and RoadBike. dditionally, it is important to note that in the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses.</p>

<p>Now for the implementation of Inheritance. Given that we already know how to create a class, we will go ahead to create a sublcass. We do this using the <em>extends</em> keyword. <br>
<code>public class MountainBike extends Bicyce{
// new fields and methods defining 
// a mountain bike to go here
}</code></p>

<p>This gives MountainBike all the same fields and methods as Bicycle. My next post aims to focus exclusively on the other two elements of OOP which are: <em>Encapsulation</em> and <em>Polymorphism</em> </p>]]></content:encoded></item><item><title><![CDATA[Object-Oriented programming in a nut-shell.]]></title><description><![CDATA[<p>The term 'Object-oriented programming'- oop comes off as a rather complex word when looked at a whole. It is a very common term that most developers may have heard, but probably not well well versed with. This is because the concept of OOP relies heavily on the concepts of abstraction</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/05/27/object-oriented-programming-in-a-nut-shell/</link><guid isPermaLink="false">a935110c-e957-4666-b651-93814c537b4f</guid><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Fri, 27 May 2016 16:31:58 GMT</pubDate><content:encoded><![CDATA[<p>The term 'Object-oriented programming'- oop comes off as a rather complex word when looked at a whole. It is a very common term that most developers may have heard, but probably not well well versed with. This is because the concept of OOP relies heavily on the concepts of abstraction and how they can heavily relate to the real world. Ideally, it is abstraction that brings the whole concept of OOP into being. </p>

<blockquote>
  <p><strong>In today's blog post, I shall only discuss about the basic terminologies of OOP as well as a low-level implementation of the same.</strong></p>
</blockquote>

<p>Breaking down OOP, we have software <strong><em>objects</em></strong> which are often used to model the real-world objects that you find in everyday life. Therefore in this case, an example of an object would be a chair. It can be physical or logical (tangible and intangible). In more technical terms, an object is an instance of a class. This means an object a single and unique unit of a class.</p>

<p>A <strong><em>class</em></strong> refers to a blueprint or a prototype from which objects are created. A typical class is defined as having various methods (or attributes), has a particular data type e.t.c. </p>

<p>That said, a simple implementation of a class declaration in Java is below: <br>
<code>public class rhapsody{
//rhapsody here is the class name
String chair; //String here is the data type <br>
method; <br>
}</code></p>

<p>Now here is a basic implementation of a class and object:</p>

<p><code>public class Rhapsody{
public Rhapsody(String name){ <br>
// This constructor has one parameter, name.
System.out.println("Passed Name is :" + name ); <br>
}
public static void main(String []args){ <br>
// Following statement would create an object
myRhapsody <br>
Rhapsody myRhapsody = new Rhapsody( "predator" ); <br>
   }
}</code></p>

<p>Compiling the above programme gives the following result: <code>Passed Name is :predator</code></p>

<p>In my next blog post,I shall discuss more concepts on OOP, with a bigger emphasis on <em>inheritance</em>, <em>encapsulation</em> and <em>polymorphism</em></p>

<p>On a lighter note:  </p>

<blockquote>
  <p>Object-oriented programming offers a sustainable way to write spaghetti code. Adios! </p>
</blockquote>]]></content:encoded></item><item><title><![CDATA[Of  'Commit logs from last night' and GitHub shenanigans]]></title><description><![CDATA[<h6 id="acaseforthegithubwillgetyouhiredbrigade">A case for the 'GitHub will get you hired' brigade.</h6>

<p>So there you are, at your most devastating hour as a programmer. You're writing code, most of it probably spaghetti code. You're struggling. You probably don't know the concept of what you're doing. You become so paranoid, you want to</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/05/25/of-commit-logs-from-last-night-and-github-shenanigans/</link><guid isPermaLink="false">096e463a-6aea-4594-8c7e-32eb3da089bf</guid><category><![CDATA[GitHub]]></category><category><![CDATA[commits]]></category><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Wed, 25 May 2016 14:26:57 GMT</pubDate><content:encoded><![CDATA[<h6 id="acaseforthegithubwillgetyouhiredbrigade">A case for the 'GitHub will get you hired' brigade.</h6>

<p>So there you are, at your most devastating hour as a programmer. You're writing code, most of it probably spaghetti code. You're struggling. You probably don't know the concept of what you're doing. You become so paranoid, you want to smash your computer screen using your fist or maybe hurl the machine outside a window. The element of being ballistic! Heh?!</p>

<p>So what goes when all decides to work? You opt for profane version control practices in the name of version control. Being the bedraggled hacker that you are, you compose this commit message that speaks levels about your frustration in the build-up to getting things right in the software you were building. Below is a day in the life of paranoid dev who just got 'stuff working'.</p>

<p><code>git commit -a -m "Made shit work"</code></p>

<p><code>git commit -a -m "Added a bunch of semi colons that were missing for some balls weird reason."</code></p>

<p>My two cents on the element of obscenity would be: while it maybe 'normal' to use a little obscene language, there's nothing cool or enlightening about it. Any site built around it is at best noisy, but more like puking all over the screen. Additionally, it's baffling by this admiration of commit messages that do nothing to explain the code committed.</p>

<h6 id="ideallyrealhackerspivottwohoursbeforetheirdemo">Ideally:Real hackers pivot two hours before their demo.</h6>]]></content:encoded></item><item><title><![CDATA[On the element of pragmatism]]></title><description><![CDATA[<p>Being pragmatic doesn't have anything to do with being a Mahatma Gandhi wannabe...or just simply doing anything weird out of the ordinary! </p>

<h6 id="sowhatis">So, what is?</h6>

<p>Picture this scenario: Imagine you applied for a job, but instead of offering you the job you wanted, they offered you a lower position.</p>]]></description><link>https://rhapsody.azurewebsites.net/2016/05/18/welcome-to-ghost/</link><guid isPermaLink="false">878ccb5b-4fa9-44b7-b4d3-1d7fc88a30f3</guid><category><![CDATA[pragmatism]]></category><dc:creator><![CDATA[Nelson Kimaiga]]></dc:creator><pubDate>Wed, 18 May 2016 13:20:53 GMT</pubDate><content:encoded><![CDATA[<p>Being pragmatic doesn't have anything to do with being a Mahatma Gandhi wannabe...or just simply doing anything weird out of the ordinary! </p>

<h6 id="sowhatis">So, what is?</h6>

<p>Picture this scenario: Imagine you applied for a job, but instead of offering you the job you wanted, they offered you a lower position. Being idealist you are, you would reject the offer, with the rationale that you would eventually find the job you wanted. As a pragmatist, you would accept the job, with the rationale that it's better than nothing and you might be get promoted or transferred to the job you actually wanted. That's to say, a pragmatist will compromise between his or her theoretically ideal outcome and the useful, practical actions he or she can actually take. <br>
Does it mean that as a pragmatic you have settle? No. You basically switch your priorities. You are someone who knows what they want, and will take a few blows for the greater idea. It's all about applied logic and reasoning. Sure you may not have the best job, but its better than nothing. Someone with more confidence in their patient theories may come out ahead, but they may lose out on all that inactive time. That time they could have been pragmatic and more forceful.</p>

<h6 id="apragmatistacceptsasituationasitisandseekstobenefitfromitasbesttheycan">#A pragmatist accepts a situation as it is, and seeks to benefit from it as best they can.</h6>

<p>N/B: Be most of the things that society does not value....and don't ever regret it.</p>]]></content:encoded></item></channel></rss>