Kayıtlar

HTTP/2

Http is an application layer protocol designed for client-server communication and can be made analogy as a kind of mail service simply with the following features: Request line; identifies the resource called. Http header ; contains operating information about the message such as destination, content type and etc. in the form of key-value pairs. Payload or body; is the part that the actual message is contained. HTTP protocol is comprised of commands/verbs such as GET, POST, PUT.. GET https://www.google.com/ HTTP/1.1 Host: www.google.com Connection: keep-alive Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) Chrome/71.0.3578.98 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7 Cookie: SID=awcwAWJ-Py1UHfnKSWSzREE01k4qY45amv6.. History of HTTP by Versions The initial versio...

Transient

In the context of Java,  the transient keyword is used as field modifier. If we declare a field as transient; that field  would not be serialized even if the class implements Serializable. private transient int count; In Java, transient is used only for fields, so methods, classes and interfaces can not be declared as transient.

Checked & Unchecked Exceptions

Checked Exceptions are subclasses of java.lang.Exception need to be declared in a method or constructor's throws clause Unchecked Exceptions are subclasses of java.lang.RuntimeException do not need to be declared in a method or constructor's throws clause In the context of common transaction APIs, such as JTA or Spring transaction APIs; any   RuntimeException  triggers rollback, and any checked Exception does not rollback the transaction. R un time R ollback Un checked

Seperation of Concerns

Seperation of concerns (SoC)   is a key software design principle that mainly states;  - different concerns of your design should not be colocated,  - meaning that different concerns should be clearly isolated with boundaries. Then what is a concern ? A concern is a way of grouping of items in a specific software development scope. For example; - In the context of object-oriented programming languages such as Java, the concerns are seperated into objects. - When the context is of service-oriented design, then the concerns are seperated into services. - In the architectural design patterns such as MVC, we seperate concerns into a kind of grouping: model, view and controller. - The question of why we put the css styles into seperate files is another good example of seperating concerns of styling from the content. - In a modular software program, different modules are seperated concerns in a way. The idea of seperating responsilities in Single Responsibility Pr...

Sameness in Java: Identity & Equality

In Java, sameness of objects is described with two different concepts: Identity and Equality. Identity  (known as reference equality) Identity of an instance is correlated with the memory location of the object. Sameness in terms of identity means that; if two references points at the same memory location then that means there is one object that is referenced by different references. Identity of objects are checked with the equality(==) operator. String s1 = "Hello"; String s2 = new String("Hello"); assertFalse(s1 == s2); However, two distinct references formed of the same string literal point to the same memory location since their references firstly looked up at String pool. Therefore when two String variables formed of same string literal are compared, the result will return true.  String s1 = "Hello"; String s2 = "Hello"; assertTrue(s1 == s2); And here is some examples about the reference equality: //Null references of same...

Don't Repeat Yourself

Don't Repeat Yourself (DRY) is a key software design principle that mainly states; - Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. ( The Pragmatic Programmer ) - Meaning simply that; do not duplicate the code written for the same business logic within a system. What are the drawbacks of DRY violations ? - If we repeate the same code within a system, maintaining the code when any logic changes will be difficult. Because the change will have to be reflected to all portions of the code having the changed logic. And the solution is ? To avoid DRY violations, business logic should be seperated into smaller and reusable units and these units should be reused via calling them wherever possible.

SOLID Design Principles

In this article, i will try to summarize the SOLID principles of object-oriented design. The concept of SOLID principles were described first by Robert C. Martin in his paper Design Principles and Design Patterns . Later on, the SOLID acronym was introduced by Michael Feathers for these principles. And here is the SOLID principles that we will outline in this article:  S ingle Responsibility O pen-Closed L iskov Substitution I nterface Segregation D ependency Inversion 1. Single Responsibility Principles (SRP) The key points that this principle says: - A class should have only one responsibility - A class should only have one reason to change - If the class belongs to domain model, it should represent only the relevant business entity. Benefits: - Testing: Less responsibility means fewer test cases - Loose coupling: Less responsibility means fewer dependencies 2. Open-Closed Principle (OCP) The key points that this principle says: - Open for extension A c...