Introduction to Angular

Image result for angular

Angular is a typescript. It provides a base for building rich client side applications ( with a specialization in data binding ) . When our UI needs to update depending on the data enter by the user .

It has component architecture which provides modularity , and re usability. Single page applications ( Client web sites applications and manage their complexity over time ) .

Angular implements a lot of JavaScript and Html .

Let’s look at Angular with a high- level view .

Angular has components. Angular is built on these components , angular runs on a component tree model . With each component we can specify an html template . When you build a component in angular you creating support a new custom element for the DOM . 

Image result for components tree angular

Directives :

directives provide functionality and can transform the DOM . There are 2 types of angular directives. Structural , and Attribute .

Structural directive is designed to alter the DOM layout .by adding or removing DOM elements : nglf , ngfor 

Attribute directives : are designed to change the appearance or behavior of the DOM elements that they are attached to. They do not create or remove DOM elements. : there’s built-int , or customs.

Angular – Pipes

Pipe : a template expression operator that takes in a values and return a new value representation. General idea you use a pipe after your statemnet that you wish to transform, the pipe will run on that value and return a final value that the template will display : there’s built in pipes, or custom pipes . 

Image result for Angular Pipe

Things to remember :

*Angular Framework * an engine from rendering markup templates through components . Easy bindign to views . And working with data  in those views .

Angular powerful features in framework dependency injection to javascript .

Spring Boot

Let’s explore what is Spring Boot :

Spring boot is a framework that essentially we can plug and play, we don’t have to do most if not all of the the configuration that we need if we wished to create an application. While also having built in tools such as jamx , restful apis, security .

Why is this so cool ? For developers this is awesome ! since it means for us we don;t need to create XML configurations , instead just use annotations . Metric , and externalized configuration . All of this makes it very easy to create stand alone applications.

Image result for spring boot

Let’s explore and get used to some terminology that we will encounter while utilizing Spring Boot :

Pom File = The heart of the maven project , where we get all the dependencies from . It is an XML file that contains information about the project and configuration details used by Maven to build the project.

Controller Layer = Responsible of handling the HTTP requests . Get , Put , Post , Delete requests. While they are sent to our server, we can offload that to our service layer .

Service Layer = Responsible of handling all business logic in the application

Image result for spring boot service layer

Repository = abstraction layer to facilitate crud operations , makes life easy for testing . mechanism for encapsulating storage, retrieval, and search behavior which emulates a collection of objects.

Lastly let’s look what dependency injection means in my own words : Providing objects that an object needs (its dependencies) instead of having it construct them itself. Which the injection can be done through a constructor . In other words giving an object instance variables.

Java – Garbage Collector

Image result for garbage collector

You know what makes java great ? the precious garbage collector .

Know apart from being my secret crush and making our life easier . The garbage collector is located in the jvm (java virtual machine) what a lovely place to be. this program runs automatically.

Image result for garbage collector - java

It will look at the heap memory , and if it find any unused objects that we will not use anymore it will delete them from the memory for us.

Your not falling in love yet ?

Ok , let’s see how good we have it .

In C/C++, programmer is responsible for both creation and destruction of objects. Usually programmer neglects destruction of useless objects. Due to this negligence, at certain point, for creation of new objects, sufficient memory may not be available and entire program will terminate abnormally causing OutOfMemoryErrors.

boy am I glad I use java am I right ?

Citations : https://www.geeksforgeeks.org/garbage-collection-java/

Spring vs Spring Java ? Spring MVC ? What are annotations used for ?

Image result for spring boot

spring is a framework that simplifies java EE development. By providing programming and config models . this is all awesome for developers in order to be more productive.

Spring boot focuses on providing with the flexibility to create , essentially one of the easiest ways to develop a web application .

Image result for spring mvc

Sping MVC = is the java framework that we used for building our cool web apps . It implements all basics features of the spring framework .

In other words , spring provides the mvc architecture and ready components to be able to used/developed web apps.

Image result for spring annotations

annotations allows us to configure dependency injection using annotation. Instead of using xml. We can move the bean configuration into the components class itself by , again using annotations .

Intro to Springboot

Image result for spring boot

Spring boot will handle our configuration for us , so we can focus on the coding part of a application, and dependencies .

It’s good to be lazy and spring boot framework provides a faster way to set up, configure , and run a simple web based application.

Smartly chooses our dependencies , and auto configures all the features that we want to use .

Image result for spring boot

So again ,

In summary :

Framework that we can plug and play , it provides some core APIS , we don’t have to do some of the configuration or set the security , things are already built in for u such as jamx stuff , restful APIS .

  • Easy to create stand alone applications
  • No need for xml configurations , just use annotations
  • Metric , and externalized configuration

Some key components :

Configuration = achieve loose coupling in a project

Dependency Injection = dynamically on the fly object creation  .

Controller layer : responsible to handle http requests . Get , put , post , delete requests . While they are sent to our server , we can offload that our service layer .

Service layer : Responsible to  handle all business logic in the application .

Repository  = abstraction layer to  facilitate crud operations . . Makes life easy for testing purposes .

DAO layer  : We need to interact to a data access object to save/receive info from a database .

Pom file = get all the dependencies . , heart of maven project

HashMaps

HashMap is a collection that is based on a map class. Utilizes key and value pairs and is writing like this HashMap<key(that you want),Value>.

Image result for hashmaps

Don’t forget to import java.util.HashMap; So you can work with HashMaps

  • HashMap doesn’t allow duplicate keys but allows duplicate values. That means A single key can’t contain more than 1 value but more than 1 key can contain a single value.
  • This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time. It is roughly similar to HashTable but is unsynchronized.

How do we put our keys , and values in a hashMap ?

Let’s look at some very useful methods that it contains . ( all code will eb available at the bottom of the page with a link to the program in my Github)

citation : https://www.geeksforgeeks.org/java-util-hashmap-in-java/

Github : https://github.com/ValorWind1/eclipseJava/tree/master/eclipse1.0/src/hashmaps

Abstract Class

 The keyword abstract is used to make a class abstract.

an abstract class can contain constructors in Java. And a constructor of abstract class is called when an instance of a inherited class is created. Moreover it can also have final methods in the abstract class.

Remember , it’s uptown you if you want to add abstract methods or not .

You might be asking what is an abstract method anyways ?

method that is declared without an implementation (without braces and followed by a semicolon)

( all code will be available at the bottom of the page with a link to the program on my GitHub)

When should you want to use an abstract class ?

  1. You want to share code among several closely related classes.
  2. You expect that classes that extend your abstract class have many common methods or fields or require access modifiers other than public (such as protected and private).
  3. You want to declare non-static or non-final fields. This enables you to define methods that can access and modify the state of the object to which they belong.

Citation :

https://dzone.com/articles/when-to-use-abstract-class-and-intreface,

https://www.geeksforgeeks.org/abstract-classes-in-java/

Githutb : https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/intermidiate_Java/abstract_Class

Static variables vs final Static variables

The match has finally arrive ladies and gentlemen .

The most anticlimactic fight in java, nevertheless it’s still important to understand the difference between them .

When we declare a variable to be static . We create a single copy is made and shared between all objects at the class level . So , static are basically global variables . Since all the instances of the class will share the same static variable .

Just remember a key point : Static variables are only created at class-level only .

(all code will be available down below this page with a link to the programs inside my GitHub )

Our output is 1 .

Now let’s look at final static variables

Final static will help our variables to be created as constants , as only one copy of the variable will/and exists and which can’t be reinitialize .

So , we created a final static variable int with a value of 10 .

Output

To see what I meant let’s try to initialize the same final static int somewhere else , and we’ll see an error :

https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/java_tutorial/static_vs_finalStatic

https://github.com/ValorWind1/VS/blob/master/training/staticVariableDemo.java

Are we there yet ? – “throws” keyword – 2nd part + checked exceptions

Welcome back people in the internet let’s continue right were we left off.

Not only do we have at our disposal , the try/catch block to catch exceptions.

Let me introduce you to :(*drum roll* ) , throws/throw keywords .

This helpful keyword , will be placed right at the end of the method’s signature .

Is there a difference between throws / throw or just the s ?

well, as it turns out throws is utilize for postponing , the handling of a checked exception ( basically procrastinating if you ask me ) . While throw is used to invoke the exception expressed.

Now , your thinking slow down there boy , I caught that. What do you mean checked exceptions ?

Turns out there’s 2 types of exceptions. Checked and unchecked exceptions. Checked exceptions will be if an exception was notify , by the all-important compiler.

Unchecked exceptions : are known as Runtime exceptions , and they happened at the time of the execution. ( bugs, not using good logic in your program )

(as always code will be available at the bottom of the page with a link to the program inside my GitHub )

yes we are, yes we are .

https://github.com/ValorWind1/Java_Review_1.0/blob/master/src/intermidiate_Java/exceptions/Throws_Demo.java

Exceptions – very exciting (try/catch block ) part 1 – New Hope

Hello , lovely people. welcome back to more coding than you can keep up with !

We will cover the exciting topic of exceptions.

Now ! pardon my enthusiasm but exceptions can indeed help you not get thrown out of your job.

How, you ask? Have I finally lost my marbles? Yes! , but more importantly exceptions will arise when an exception event occurs.

However, is not because of your perfect program, on the contrary it will be when a problem arises while the program it’s being executed.

Now don’t feel too bad yourself , There are times when exceptions occur and it wasn’t our fault !! ( I know that’s incredible )

But , they may happen when a user has entered an invalid data. A file that needed to be found was not found, or if you are really unlucky the network was lost.

So , if you are like me , and have been playing Pokemon go you are internally telling me how do I catch this pesky exceptions.

Say no more I bring to you the all mighty try/catch block , and the method caller “throws”.

( all code will be available at the bottom of the page with a link to the program inside my GitHub )

For, our example let’s look at a nice array with an index value of 6 .

However, If I want to win a poker game I want to access my favorite lucky number 7 !!

So , I prepare in case something goes wrong , and implement the try and catch block . For this scenario we will be using the ArrayIndexOutOfBoundsException

what nice , compact name am I right ? , anyways if for some mysterious reason something goes wrong we will print . ” We catch an exception “

Finally , we want to give our greedy user to turn back , and lower his/her access index value .

https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/intermidiate_Java/exceptions

The SUPER keyword

This keyword not only has the best name , but it comes from the concept of inheritance .

by reducing the amount of code that we need to write , inheriting allow us to control multiple classes and their content with one parent class.

The class that is being inherited from it’s called the super class , and the class that inherits is call the sub class.

all of the code will be available at the bottom of the page , where there will be a link to my program from my GitHub !!

The super keyword it’s a reference to the parent class, and it’s objects.

We have our base class where we want our subclass/ child class to inherite from.



ok so we , have a method let’s call it .

if we didn’t have the super. It wouldn’t have call the method inside our parent class let’s see the evidence :

https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/java_youtubeclips/superDemo

What is the purpose of THIS keyword .

Don’t get confused I’m talking not about that this but , about THIS this keyword .

Are we confused yet ? good , lets get started . Using the this keyword can allows us to have multiple constructors in the same class. how ?

well the keyword has a pointer to the object that it’s currently in. So , you can use the this keyword on non static methods or constructors

Let’s look at some code to paint a clear idea. ( The code will be available down at the bottom of the page where you will see the link of the program from my GitHub)

Cool ! , we have a class that contains 2 strings named a ,b . And it just so happens we have a constructors we the same names .

Now , this is exactly of those times you want to use this . Because we are specifying a field in a new variable, which have the same name .

So essentially , what we are doing is to specify that the variable that indeed does have the name is not a local variable , but an instance variable.

Output :

If we didn’t have the this keyword let’s see what happens :

ooops ! , our program doesn’t know what our intentions are. We have to write to it precise instructions .

https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/java_youtubeclips/this_keywordd

Keyword to achieve inheritance

Hello guys , Let’s go over the concept on how we can achieve inheritance.

To be straight to the point to those in rush hour. you use the keyword : extends

Now , for the rest let’s take a deeper dive into the code .

Let’s create a base class , that contains a method ( all of the code will be available at the very bottom, of the page as a link to the Repository from my GitHub)

We create a new class named Ferrari and we write extends to our base class Cars .

Let’s do the same for another class called Tesla

We will call them now in our main class

Remember that our 2 SUBCLASSES didn’t have any methods inside of them right ? : how is this going to work you might ask .

Well , when you extend a subclass to a parent class what you are doing is obtaining everything inside the parent class. So even if we don’t see anything inside of those 2 classes. We must have faith, in our programming languague !

OUTPUT :

Look at that it did work ! , awesome so now we know how to inherite by using the keyword extends !!!.

https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/java_youtubeclips/inheritance

HTML Text Formatting

Welcome back in the past Blog , we talked about HTML attributes. Now We are going to cover something call text formatting. That will allow us to define special elements for our written text in an element. For example <b> will be used if you want to bold letters, in other hand if you want italic you want to use <i>.

List of text formatting elements :

<b>Defines bold text
<em>Defines emphasized text 
<i>Defines italic text
<small>Defines smaller text
<strong>Defines important text
<sub>Defines subscripted text
<sup>Defines superscripted text
<ins>Defines inserted text
<del>Defines deleted text
<mark>Defines marked/highlighted text

even if <em> displays the same in browsers as <i> , there’s still a difference in the meaning behind them . the tag < em > is to give/ used to signalized that a text is important

When to use <small > tag ?

When you want to make your text smaller, you can do this inside a paragraph .

Hey ! but I want to show off the effect in my text of being deleted how do we do this ?

say no more , my dear reader for your desires I give you the <del> tag.

Now I know what you ‘ re thinking you want to highlight important text elements, that will allow you to catch the attention of your readers when they are in you awesome website .

I give you the <mark> tag that will allow us to highlight

There’s a few more try to play around with them , get comfortable and you will be able to obtain more control over you text, and display the way that you personally want it to be displayed

Citation : https://www.w3schools.com/html/ , vhttp://www.simplehtmlguide.com/text.php , https://www.tutorialrepublic.com/html-tutorial/html-text-formatting.php

HTML Attributes

All elements in HTML are able to have attributes , attributes are helpful because they will allows us developers to give more information about an element of our choosing. Remember that attributes are specified at the start of the tag itself, and most often than note come in value pairs like name = “value”

Our link will be named SOUNDTRACK LINK

Another Ex :

We can have attributes for our desire picture where we can specified the sized that we wish for the picture to have , once displayed in the web site.

A very popular attribute is the style attribute :

The style attribute will allow us to specify more deeply the styling of the such as the : element, like color, font, size etc.

List of HTML attributes :

altSpecifies an alternative text for an image, when the image cannot be displayed
disabledSpecifies that an input element should be disabled
hrefSpecifies the URL (web address) for a link
idSpecifies a unique id for an element
srcSpecifies the URL (web address) for an image
styleSpecifies an inline CSS style for an element
titleSpecifies extra information about an element (displayed as a tool tip)

Does it matter if we use double or single quotes for our attributes ?

Double quotes using on your attributes values are the most used in HTML, but single you can use single quotes as well. The only exception being that in some situations, the attribute value itself contains double quotes, it is necessary to use single quotes:

Citation : https://www.w3schools.com/html/html_attributes.asp , https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes