Author Archives: 3electrones

REST-API

In past few week we have working with REST API, and how it works. we have learned lot of thing about REST-API code and how you implement them to create WEB-order. Today I am going to tack about what is REST API is and how do you implement them using Docker Plate-form. So, What is REST API? REST API acronym is REpresentational State Transfer. There are six Guiding Principles of REST. Client-server, stateless, Cacheable, Uniform interface, Layered system, Code on demand witch is optional.

Client server is Separating the user interface concerns from the data storage concern. Stateless Each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client. Cacheable Cache constraints require that the data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable. Uniform interface is applying the software engineering principle of generality to the component interface,  the overall system architecture is simplified and the visibility of interactions is improved. Layered system is style layered, it allows an architecture to be composed of hierarchical layers by construing component behavior such that each component cannot “see” beyond the immediate layer with witch they are interacting. Code on demand witch is REST allows client functionality to be extended by downloading and executing code in the form of applets or scripts. This simplifies clients by reducing the number of features required to be pre-implemented.

The Key abstraction of information in REST is a resource. Any information that can be named can be a resource: a document or image, a temporal service, a collection of other resources, a non-virtual object (e.g. a person), and so on. REST uses a resource identifier to identify the particular resource involved in an interaction between components.

Another important thing associated with REST is resource methods to be used to perform the desired transition. A large number of people wrongly relate resource methods to HTTP GET/PUT/POST/DELETE methods. A lot of people prefer to compare HTTP with REST. REST and HTTP are not same.

Here is example of REST-API from .YML file. In this file you write docker script file to tell how your website to be. In this file image you see the tag, summary, operationID, Response for each code and much more…

Resources: https://gitlab.com/LibreFoodPantry/training/microservices-activities https://searchapparchitecture.techtarget.com/definition/RESTful-API

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

JavaScript

In Past class session we are learning a lot about docker. Not just docker but also how it work with Java & JavaScript. Today I am going to introduce JavaScript and how it work in docker. So let’s start what’s different between Java and Java script. So Java applications are run in a virtual machine or web browser while JavaScript is run on a web browser. Java code is compiled whereas while JavaScript code is in text and in a web page. JavaScript is an OOP scripting language, whereas Java is an OOP programming language.

Do not confuse JavaScript with the java programming language . Both “Java” and “JavaScript” are trademarks or registered trademarks of Oracle in the U.S. and others countries. However, the two programming languages have a very different syntax, semantic, and use.

JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class function While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.jsApache and Adobe. JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. The Docker  platform allows developers to package and run applications as containers. A container is an isolated process that runs on a shared operating system, offering a lighter weight alternative to virtual machines. Though containers are not new, they offer benefits — including process isolation and environment standardization — that are growing in importance as more developers use distributed application architectures.

  • JavaScript is used in Web Application Development. Some of the examples are -NetFlix, Facebook, Uber, LinkedIn etc.
  • JavaScript is used in Mobile Application Development. Some of the examples are- Spotify, Instagram, Facebook, Skype, Uber etc.
  • JavaScript is used in Game Development. Let’s see some games where JavaScript is used- Angry birds, Candy Crush ,Systems Offline, Re-wire, Offline Paradise etc.

Runnig JS code in browser: A good way to learn JavaScript is to run it in browser’s JavaScript console. Just open your favorite browser and press F12 key or Ctrl + Shift + I on your keyboard.You will see something like this on the screen now click on the console tab which I marked. And thats your plaground, yes you heard me correct you can write javascript code here. Lets write our legendary program here and see.You will see something like this on the screen now click on the console tab which I marked. And thats your plaground, yes you heard me correct you can write javascript code here. Lets write our legendary program here and see.

here is link to instruction on How To Build a Node.is Application with Docker.

https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker

https://www.oreilly.com/library/view/javascript-the-definitive/9781491952016/ch01.html

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

Facade Design Pattern

This week we practice docker a lot bout docker Activity, but we havent learn all about patterns so I choose to write one more Main Design Pattern call Facade Design Pattern. in my homework 3 I picked Decorated design pattern but I have’t learn more about Facade Design Design Pattern. This is really help full in programing becuse it have high level interface that make subsystem easier to use.

Facade design pattern provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.Facade pattern is one of structural design pattern among other Gang of Four design pattern. The facade pattern is appropriate when we have a complex system that we want to expose to clients in a simplified way. Its purpose is to hide internal complexity behind a single interface that appears simple from the outside. Facade also decouples the code that uses the system from the details of the subsystems, making it easier to modify the system later.

To understand the facade, let’s take a very simple example of a desktop computer machine. When we have to start a computer, all we have to do is press the start button. We really do not care what all things go inside the computer hardware and software. It is an example of Facade pattern.

In Java programming, we must have connected to a database to fetch some data. We simply call the method dataSource.getConnection() to get the connection but internally a lot of things happen such as loading the driver, creating connection or fetching connection from pool, update stats and then return the connection reference to caller method. It is another example of Facade pattern in the programming world. Similarly, we can find a lot of more examples which hide lots of internal complexities and provide simple to use interface to the programmer to work with the system. All such are facade examples.

Remember facade does not reduce the complexity. It only hides it from external systems and clients. So the primary beneficiary of facade patterns are client applications and other systems only. It provides a simple interface to clients i.e. instead of presenting complex subsystems, we present one simplified interface to clients. It can also help us to reduce the number of objects that a client needs to deal with.

When you call a shop to place a phone order, an operator is your facade to all services and departments of the shop. The operator provides you with a simple voice interface to the ordering system, payment gateways, and various delivery services.

Source:

https://refactoring.guru/design-patterns/facade

https://www.tutorialspoint.com/design_pattern/facade_pattern.htm

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

Decorator Design Pattern

In this class we have learned Few design pattern and when you look at history of pattern there are several design pattern out there that I haven’t learned. Well today I am going to tack about Decorator design pattern where I am going to show you how I used it to make my code look professional. With Example. Let’s start with what is Decorator Design pattern and how can we implement it in code.

Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. The intent is to attach a responsibility to an object at runtime. Sometimes we want to add a responsibility to an object A, not its whole class. … This can be done by wrapping A in another object that adds the responsibility. In other world clint has freedom to create object and then extend it by adding a varity of future to it. just like weapping a gift, putting it in a box and weapping the box.

What are success and failure of using this pattern? So let’s start with successes when you use this pattern in code extend an object’s behavior without making a new subclass., You can add or remove responsibilities from an object at runtime.,  also You can combine several behaviors by wrapping an object into multiple decorators. Now the failures so  It’s hard to remove a specific wrapper from the wrappers stack., The initial configuration code of layers might look pretty ugly.

now let me give you example of how I used it in code.this is just Class diagram. With Step by step about how to implement it.

Step 1: Create an interface FlyBehavior.java witch is blue print to the class which we will Decorate.

Step 2: Create concrete classes implementing the same interface. like FlyWithWings.java and FlyNoWay.java witch will create dynamically.

Step 3: Create abstract decorator class implementing the Shape interface like Duck.java witch contain refrence to interface.

step 4: Create concrete decorator class extending the Duck.java class. RedHeadDuck.java

Step 5: Use the RedHeadDuck to decorate DuckSimulator objects. witch will verigy the outPut.

Now how this pattern have connection with other pattern. Adapter changes the interface of an existing object, while Decorator enhances an object without changing its interface. Decorator lets you change the skin of an object, while Strategy lets you change the guts. Composite and Decorator have similar structure diagrams since both rely on recursive composition to organize an open-ended number of objects.

Reference:https://www.geeksforgeeks.org/the-decorator-pattern-set-2-introduction-and-design/

https://refactoring.guru/design-patterns/decorator

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

Docker

Hey guys welcome to week 4 blog. This week I am going to talk about Docker and why is Important. we learn about this in last few classes and I am writing about this platform because it help me and you getting deep understand about how to operate and use this application in seitan way. so let’s start this with what is Docker? so docker is tool that designed to make it easier to create, deploy, and run application by using Containers. It includes packages, libraries and other dependencies. You probably wondering how this Work. Well it’s work on Virtual machine. It kind a uses Linux machine. And importantly, it’s open source!!!

you wondering, who is Docker for? Docker is a tool that is designed to benefit both developers and system administrators, making it a part of many DevOps toolchains. For example developers can focused on writing code without worrying about the system that it will ultimately be running on. it also allows them to get a head start by using one of thousands of programs already designed to run in docker to run in Docker containers part of the application. I have used programing platform call QT. Qt is software development platform where you can write code and make you own application and it require a C++ language to run your software. but Docker run on command line. this make developer really easy to developer application and Quicker too.

This container can be thought of as necessitating three categories of software: Builder, Engine, and Orchestration. the main point of using this is making application build faster and docker is way to do it.

Now I will tell you why Docker is good for data Science. When I started as a Data Scientist my focus was always on finding the best algorithm by conducting experiments that would improve my model’s performance. I never really thought much about how I would share my findings and code with others, other than Most of this was the environment setup. In many cases, it would be time-consuming and I would give up and get on a call with the main Developer. when you data Scientist you deal with data a lot and also as algorithms. when you run data in Docker you build Docker Image , Run Image.

Sours: https://opensource.com/tags/docker

https://www.docker.com/blog/

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

Design Pattern

I remember when I was taking CS 101 And CS 102 I always write something that does needed in code or write one same code in different classes or making easy code really difficult and I still do. It’s really hard to write perfect code. This is why I chose this design pattern topic to write this blog. In this blog I will show you how I was writing code in beginning of computer science and How I write my code Now. I will show what makes changes in and how I did it.
Let’s start with how I was writing Poorly designed code that caused problems with systems, making them hard to understand, modify, and maintain.We can says that some of this poorly designed code as specific design smells. When I Went back too look at my code I found that my code had problem like I writhing long Method , Duplicate code , Rigidity,Fragility, Immobility, Viscosity, Needless Complexity, Needless, Repetition. This all is define that I was writing poor code. This kind a smell will prevent you from getting a job and it will extend time to make software too.The difficulty this creates in maintaining and modifying code this is called technical debt and can be removed by refactoring.

We we want to design software that is easy to maintain and easy to modify. But, the obvious solutions to design problems can lead to brittle software that cannot be modified or maintained easily. Design patterns represent common software design problems and well-tested solutions to those problems.There are are more than 1 type of design pattern where you can use in code to make it look professional. Today we will look at That pattern that I used in my code Call Singleton design pattern so this pattern is about define a class that has only one instance and provides a global point of access to it. In easy way a class must ensure that only single instance should be created and single object can be used by all other classes. In bottom you will example of Singleton design.

In this example How Price class GFC is implemented in public class. And this will make your code really easy and you can access it any time . The application of Singleton design pattern have multiple Uses you can Hardware interface access, logger, Cache, and many more Way. After learning couple of pattern my code improved and made it professional.
This are main point of learning of Singleton classes.

  • Singleton classes can have only one instance and that instance should be globally accessible.
  • java.lang.Runtime and java.awt.Desktop are 2 singleton classes provided by JVM.
  • Singleton Design pattern is a type of creational design pattern.
  • Outer classes should be prevented to create instance of singleton class.

Source : https://learning.oreilly.com/library/view/head-first-design/9781492077992/ch05.html#the_singleton_pattern_one_of_a_kind_obje

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

UML Diagram

In today’s blog I’m gonna talk about UML diagram. This week in the past we learn how to draw email diagram and how it helps in software developing and designing. We also learned how programmers use this UML diagram to write code in class object and much more. This is directly related to the course materials in and computer science major this block will help the readers how to draw your UML diagrams and then write a code based on that.

i’m gonna start with what is your UML diagrams. UML, which stands for Unified Modeling Language, is a way to visually represent the architecture, design, and implementation of complex software systems. This language helps programmers to visualize the software and helps them developing code.I’m gonna talk about types of your mail diagram there are five component of uml diagram. Class, object, inheritance, Abstraction,and polymorphism. Below show definition of those component.

  1. Class –A class in UML diagrams tells the basic idea of the structure and functions of an object used in class.
  2. Objects –Objects help us break down large structures and allow us to modulate our behavior.
  3. Inheritance –Inheritance is a process by which child/Subclasses inherit the characteristics of their parent/Superclasses.
  4. Abstraction –It is the process by which implementation details are hidden from the user end.
  5. Polymorphism –It is the method by which functions or entities are to show themselves in more than one foam.

    People chose this because UML Because it helps strategic value of software increases for many companies, the industry looks for techniques to automate the production of software and to improve quality and reduce cost and time-to-market. These techniques include component technology, visual programming, and pattern. The Unified Modeling Language (UML) was designed to respond to these needs. this tool is really easy to use when you understand everything. This diagram helps Support higher-level development concepts such as collaborations, frameworks, patterns and components. And Integrate best practices.

    There are many ways to write or draw UML diagram. You can Draw it by pen or pencil or online tool like visual-paradigm that Han help developer to draw class and object UML diagram FOR FREE.

    we all know that your UML diagram is REALLY difficult to write or draw. I am going to explain what each symbol and sign mean in UML Class diagram. Link below show how UML diagram can be drawn. There are things in there you can look at like UML Class Notation, Class Visibility, class attribution, Class operation, Parameter Directionality, Relationships between classes and much more…

SOURCE: https://www.techtravelhub.com/what-is-uml
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml/

free UML diagram: https://online.visual-paradigm.com/diagrams/solutions/free-class-diagram-tool/

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.

Introduction

Hey class!!! it’s Meet Patel. My major is computer Science with Software Development and this whole pandemic sucks. 😦

From the blog CS@Worcester – </electrons> by 3electrones and used with permission of the author. All other rights reserved by the author.