Saturday, May 31, 2014

Classes and Objects (in C#) with Example

A program is made of pieces that all interact with each other to make a functional program. Think of a human body. We have organs that each have their own function, but ideally, they will all work together to keep us alive. These small parts will be individual programs and have their own purpose and function, but to make a bigger product. Our class would be "organ". Every organ is made up of cells (attribute), and every organ uses energy (method).

So our brain is a type of organ, hence brain would be an object we created.

Brain specifically has the same property where it is made of cells and it has the method of using energy. However, it has additional properties (contains blood brain barrier) and methods (sends electrical signal using neurons, capable of interpreting thought/senses) that are SPECIFIC only to the brain. You want your class to have properties/methods that apply to almost all of the objects within it. And then you can specify more about each object when you create them.

We will start simple with some definitions to reiterate what I said above-- and then we can take the human body as an example and put it into the code (using C# as our example):

What is a class?
Classes can be regular or abstract. A regular class is a "prototype" of sorts for the objects to be created from. It will contain all of the attributes and methods that each object created from it will own (the objects will inherit the properties and methods of the class). An abstract class must declared abstract (and may/may not have abstract methods). Abstract classes cannot be instantiated. However, you can subclass an abstract class.

What is a object?
An object is an instance of a class. It will inherit the characteristics of the class (since we make an object to be a type of organ, we can make a brain. A brain is made of cells (attribute) and uses energy (method)). In addition, you can add more attributes and methods specific to the brain. And then you can make another object, like a heart.. which will have the same inheritance from the class (made of cells and uses energy), but the heart has large blood vessels (attribute), and it supplies the body with blood (method).

How do I make a new object?

You call on the class "Organ" and follow it with the name of the new object you want to make, here the new object is called "brain". "new Brain" simply creates the actual instance of the object.



This is equivalent to the statement above! Up to you on which one you prefer to write.



And if you have a bunch of brains.. well you can just name the new one 'x'.. or any other variable/name of your choice.


How do I actually connect them?
You use a colon sign to connect them, and now the brain will inherit the attributes and methods of the organ.

Other object oriented languages are C++, Objective-C, C#, Java, Perl, Python, Ruby and PHP.

We are trying to avoid being very linear and running thousands of lines of code with repeating text. Who wants to read or edit that?

Friday, May 23, 2014

Introduction to C#

I am going to start very simple, because by far I believe it is important to understand these basic concepts and what they do! If you open a new C# Console Application in Visual Studio (free to download and use the Express version!) you will see the following:

The console referred to throughout the code is the operating system window (think black screen associated with MS-DOS). This console is what will interact with the referenced System (the operating system). The namespace helps you keep organized and holds your class and method name! System is a namespace. And, Console is a class within the namespace System. By having the "using" directive at the top, it prevents you from needing to specify the actual namespace for every class.

And, importantly.. you require static void Main(string[] args) allows you to tell your program to start reading your code and working!

Class is fun (well-- not school classes, but..)! Classes will describe objects. This goes for all object orientated programming languages, so the great thing is the concepts stay the same and only the syntax changes. Think about how different languages essentially communicate the same ideas, but are written, structured, and spelled differently. Classes are an abstract idea of something that is intangible. Classes have properties which are attributes of it, and methods which are things it can do. An Object is an instance of a class, and it will inherit all of the properties and methods of the class.

Telling the Console to "WriteLine" causes text to be printed on the black output window for you to see. The only reason you can see this though is if you write Console "ReadLine" also (this tells the Console to slow its mega fast computer thinking power down to our human level.. and it will wait for us to input something or to exit the program.. without this text, the program would be inputted, done, outputted, processed, and gone before we could understand what even happened). There are also things called Console.Read() and Console.Write(), what these do differently is that they will read/write only the next character from standard input. Whereas our selection of Console.ReadLine()and Console.WriteLine() reads everything until the end of the characters (which is usually what we want to do).

I will write more on individual topics later on, I just wanted to introduce the idea at the moment!

And, finally.. the world of software is a great place that lives on the Internet and in the great mind of people who build the ideas for it. The Internet is your own free personal library to learn just about anything, including (and especially) what it is built upon! I hope that I can help someone new by explaining it in my own words and coming from how I perceived when it was a new concept. I hope to share many more introductions to software, ideas about it, and snippets of cool new projects.

Sunday, May 18, 2014

HTML vs. CSS overview

I just want to introduce the concept of HTML and CSS if you are completely new to it and clarify the difference between the usage of each. This is great if you have never seen it and want the meat/potatoes of what you will use-- or if you are like me and have done this many times over the years and just need a little ;) reminder sometimes.

What is HTML (Hyper Text Markup Language)?
Well, this website (and most websites) are displayed to you in the form of text. But whether the text is in a new paragraph, bolded, underlined, or italicized is determined by HTML. Links to my home page or some other page are written using HTML. Images are called upon with html also. There are many, many more things you can do with this and other languages out there. In addition, all the words in your documents on your computer-- for example Microsoft Word will save you files with all your special formatting choices in text size/boldness/etc. using HTML and will read all the HTML so the document is the same when you open it again and again. So HTML is not just for the web!

You can mix/match, learn as you go, or figure things out in application to your own projects! Tons of great ways to learn how to do this. Its really just a way to tell your computers to do things.. because they don't talk like you and I do. Let me show you how the above paragraph looks to me when I am writing to you in the blog. Here it is (insert MAGIC):

Keep in mind I am using a neat little tool called SyntaxHighligher which I had to enter into the blog template in order to display this to you! If you want to open your own blog on Blogger or WordPress and be able to show code, you can go to their website by clicking: HERE.

Also notice that every tag in in diamond brackets "< >" have to be opened with what I tell it to do. And then the diamond brackets are closed with a "/" at the end! They keep things simple here! p is for paragraph. br is like hitting the enter key one time. b is for bold. u is for underline. i is for italics. a href opens a link. img src calls a picture (that you have to upload to a server and pull its URL from). And there is lots, lots more you can do.

What is CSS(Cascading Style Sheets)? What is different about this one?
Again, and similarly.. CSS lets you change your font text/boldness/italics. Also it will let you break a page into columns. So it c Web-based HTML = tends to be data/information presented to you. CSS = appearance of your website. You have little mixes and bits of both, and sometimes Javascript.. so all these can be on one web page! If you use things like Dreamweaver, they will take care of it for you. If you are doing it on your own, it may be good to try to understand exactly what does which and which one is neater/more effective for what you want to do. There is some overlap what they accomplish. The syntax is different enough that once you get used to seeing them, you will be able to easily pick apart the difference between them on a web page.

Summary time!
HTML (Hyper-Text Markup Language) = web content and structure.

  • Position and size (heights and widths) of website images, logos, sidebars, text, menus, and content.
  • Headers, content, footer, and sidebars.. their position and existence.
  • Again.. your CONTENT!!! :)
  • The bullets on this page where I am listing things, all the organization of my text, the example above..

CSS (Cascading Style Sheet) = layout design.
  • The color of the background, areas in the header/footer/sidebar...
  • Whether a width is fixed and centered/left/right..
  • General colors, sizes, positions, the look and feel of a website!

Note also, CSS can go into HTML files so CSS is more flexible and mixable. But, HTML cannot go into stylesheets. Some of these things can be interchangeably done, but always try to use the one better suited for the task and that will be easier to edit in the future and has the neater syntax.

Friday, May 16, 2014

Agile Development

Agile Software Development methodology

Agile methodology is described as “iterative” and “incremental.” Iterative = small reasonable (bite-size!) goals. These manageable goals are known as "Sprints" or "iterations". The team should have a packaged increment (= progress!!!) at the end of each of these.

Agile was born in order to fix the problems of the Waterfall method. Waterfall is a very sequential linear process that has 8 steps: conception, initiation, analysis, design, construction, testing, implementation, and maintenance. The problem is, things are not completed piece by piece and checked.. all of the groundwork and plan is done initially and executed, then tested, then the final product is made. The teams of people working are often separated by their roles, and there is less cooperation. This leaves no room for changes or getting to see pieces of the product. So, there is a good chance the client may terribly dislike what they get at the end, and then there is nothing much to be done except scrap the project and start completely over-- which leads to a higher cost and time than if something else, such as Agile, were used.

An Agile team involves a mix of all the people involved: business analysts, developers, testers, and input from the client! The team will make a plan for their sprint on what they want to accomplish. There is a burndown where teams assign story points to their tasks.. this should not be solid numbers that can be compared to one another because this sets unrealistic deadlines on the team (and Agile is built to prevent this!). To help mitigate the issue, often the story points will count up in intervals without an easily definable pattern. Some companies uses Fibonacci series or T-shirt sizes to make the sizes somewhat of an eyeball measurement, but not something that can have a definition and date slapped onto easily. If it was 1, 2, 3, 4, 5, 6.. well you would expect 6 to take 6x as long as 1 and 3x as long as 2. If its Fibonacci or T-shirt sizes.. while you can do some fractions or exact calculations.. it is meant to just show if its "big", "huge big gigantic", or a "small-ish" task.

This team works on their Sprints/Iterations for a certain interval.. this could for example be something like 2-4 weeks. Each member takes a piece, works on it with the other members so that it is developed, tested, and shown to client for input. Afterwards, the team will debrief and decide what worked/didn't work depending on how far beyond/behind they were of their goals. All in all, this gets software out quicker because things are checked along the way and the client is aware of the progress and how it looks. Changes can be made, and as we know.. software is about change! There are always new things coming out and interfaces/OOD is there for implementing these new ways for the software to work.

Sunday, May 11, 2014

Introduction to JavaScript pt. II

JavaScript is a programming language found all over the Internet; almost all HTML webpages now use this. In the past it was more rare. If you All modern HTML pages are using JavaScript. I compared and contrasted HTML and CSS HERE. Now, I want to talk about the 3rd component of the majority of web pages.

So remember: HTML has most of the content of your page, CSS will make your design/layout, and now JavaScript will script the behavior of parts of the page. Some of what they do overlaps. In the past, a version of Internet Explorer had issues implementing your css to what the browser showed users so it was better to use HTML or Javascript instead. Now the three are pretty essential components!

Essentially, you have your html webpage and it opens itself by saying.. well html. They keep it logical! In the body, you put your script tags to open up your Java .. script. Let's start with an real example! Keep in mind you must put everything in the diamond bracket "< >" tags with the opening and closing slash and the word script. I believe the BEST way to learn is to do. So, let's look at a few examples. Try to understand what is happening. And, at the very end, I will explain it to you! Let's begin:

Button Click example:

Write stuff here.. happy little stuff.. look here when you click the button below..

Okay, another one! The JavaScript starts in the next sentence below! You'll see how it is put together in the code sample afterwards.

A paragraph away from the other ones, like p in HTML.

Text separated like a br in HTML
More of that...
And even more..

Ok more examples..this one is doing some simple math:

We will make x = 2 and show what happens if you add 18. Then you multiply that whole sum by 5.

One last one, this is useful for trying to linearize input from users. Say someone puts in names in capitals and lower case mixed, or all caps, or whatever.. and your program can only read lowercase. You can make their input all into lower case.

SEE all this MEsSy UPPERCASE stuFFs??? ClicK and UPPERcase NO mOar!

Okay, so now I will try and explain what is common about all these examples. You open and close with script. In these examples, you have to call function in order to tell the computer you are about to do something. You name the function something directly after, here it is often "myFunction" so you write: "function myFunction". The elements have ID's which can be any variable. I often choose x, y, z.. or some other name related to what I am trying to do. Anything in quotation marks are variables, names, or things the user will see when they use your little script program. Things like innerHTML and toLowerCase are the functions built into JavaScript that actually do what you want them to! You can look these up online and you will get used to which ones are available (I think of these as my available tools). Most things like arithmetic, date/time, and others are already thought of and done! Of course you can make your own as your progress and do whatever you would like with them to tailor them to your task.

Monday, May 5, 2014

Entity Framework

A software framework helps out by providing a general function for something that many, many people have to go through (it makes life easier). Usually people have a very monotonous task and everyone has to do it-- and then someone says "Hey! I have a great idea that would make everyone's life better!" And thus, is born a framework. Its reusable and works on all kinds of software platforms for applications, products and solutions. Some examples of supportive frameworks Software frameworks include support programs, compilers, code libraries, tool sets, and application programming interfaces (APIs) that bring together all the different components to enable development of a project or solution. Entity Framework (EF) helps map data to domain specific objects in the solution. You can view the architecture of it below:

EF will automatically fill in the data access code for the developer and simplifies the process of linking tiers together. If you don't already have it on a project solution, you can get it from NuGet (in VS 2013: Tools > Library Package Manager > Manage NuGet Packages for Solution). NHibernate does a similar linkage for .NET (Hibernate is the Java counterpart), however Entity Framework may be simpler/more compatible with everything because it is a Microsoft add in for an already fully Microsoft environment. It provides easy management of the following relationships between data tables: "one to one", "one to many", and "many to many" (see following screenshot). And of course, you can use the CRUD (Create, Read, Update, Delete) operations on the database.

Entity Framework is part of the ADO.NET technologies set and allows LINQ to be used with SQL, DataSet and Entities. As of June 20th, the latest version is out which is EntityFramework 6.1.1.