DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Latest Articles - DZone

article thumbnail
Travis CI vs Jenkins: Which CI/CD Tool Is Right For You?
The ultimate showdown between Travis CI vs Jenkins. Check out this guide to know who wins the race!
August 27, 2020
by Himanshu Sheth DZone Core CORE
· 13,346 Views · 16 Likes
article thumbnail
Mitigating DevOps Repository Risks
Docker is in the news for two reasons: Image retention limits and download throttling. Let's discuss both and see the better alternatives.
August 27, 2020
by Pavan Belagatti DZone Core CORE
· 20,441 Views · 4 Likes
article thumbnail
Part 3: How to Develop a Data Integration Master Test Plan
In the final data integration series article, we'll show you how to develop a data integration master test plan, the cornerstone of data verification efforts.
August 27, 2020
by Wayne Yaddow
· 5,908 Views · 2 Likes
article thumbnail
Tutorial: Data Ingestion From Kafka to Azure Data Explorer
Use the Azure Data Explorer sink connector to ingest data from Apache Kafka.
August 26, 2020
by Abhishek Gupta DZone Core CORE
· 7,136 Views · 6 Likes
article thumbnail
Raspberry Pi Cluster Emulation With Docker Compose
This guide discusses everything needed to build a simple, scalable, and fully binary compatible Raspberry Pi cluster using QEMU, Docker, Docker Compose, and Ansible.
August 26, 2020
by Sudip Sengupta DZone Core CORE
· 15,476 Views · 6 Likes
article thumbnail
7 Best Practices for Salesforce Testing
In this article, take a look at seven best practices for Salesforce testing, such as thorough unit testing, getting the right testers, and more!
August 26, 2020
by Niranjan Limbachiya
· 11,537 Views · 4 Likes
article thumbnail
Limitations of Linters—Is it Time to Level-Up?
While linters have been around for a while and offer basic code checks, many developers are starting to ask for more comprehensive insights into their code.
August 26, 2020
by Akansha Yadav
· 4,782 Views · 4 Likes
article thumbnail
Grafana Analysis and Visualization with CA APM
This article is an analysis and visualization of Grafana, a multi-platform open-source analytical and visualization tool, with CA APM.
August 26, 2020
by Prem Prakash
· 4,460 Views · 3 Likes
article thumbnail
Ultimate Tutorial about Microsoft Graph APIs
This tutorial demonstrates some of the features of Microsoft's Graph API and outlines what you can expect when you use it.
August 26, 2020
by Daria K
· 9,949 Views · 2 Likes
article thumbnail
How to Give Access to AWS Resources Without Creating 100s of IAM Users
This post demonstrates the use of AWS Security Token Service to give access to AWS Resources to users that don't exists in AWS IAM.
August 26, 2020
by Rajan Panchal
· 5,471 Views · 3 Likes
article thumbnail
Hello World Scala in the Cloud With Spring
In this tutorial, we are going to look at Scala using Spring MVC and MongoDB.
August 26, 2020
by Otavio Santana DZone Core CORE
· 13,724 Views · 4 Likes
article thumbnail
C++17: Polymorphic Allocators, Debug Resources and Custom Types
In this article, take a look at polymorphic allocators and see how to debug sources and custom types.
August 26, 2020
by Bartłomiej Filipek
· 17,415 Views · 4 Likes
article thumbnail
Getting Started With SQLPad and Distributed SQL on Google Kubernetes Engine
See how to install a 3 node YugabyteDB cluster on Google Kubernetes Engine, build the sample Northwind database, build and configure SQLPad, and more!
August 25, 2020
by Jimmy Guerrero
· 6,027 Views · 3 Likes
article thumbnail
Microservices for Java EE/Jakarta EE Developers
With this article, our intention is to illustrate that microservices are a valid option for Java/Jakarta EE developers with the help of Payara.
August 25, 2020
by Fabio Turizo
· 8,853 Views · 5 Likes
article thumbnail
Json Web Token: How to Secure a Spring Boot REST API
In this post, I show how to secure Spring Boot REST API using Json Web Tokens for authorization. We will also use Spring Security in this tutorial.
August 25, 2020
by Yogesh Mali
· 53,496 Views · 17 Likes
article thumbnail
Adapter Design Pattern in Modern C++
In software engineering, Structural Design Patterns deal with the relationship between object and classes i.e. how objects and classes interact or build a relationship in a manner suitable to the situation. The structural design patterns simplify the structure by identifying relationships. In this article of the Structural Design Patterns, we're going to take a look at Adapter Design Pattern in Modern C++ which used to convert the interface of an existing class into another interface that client/API-user expect. Adapter Design Pattern makes classes work together that could not otherwise because of incompatible interfaces. By the way, If you haven't check out my other articles on Structural Design Patterns, then here is the list: Adapter Bridge Composite Decorator Facade Flyweight Proxy The code snippets you see throughout this series of articles are simplified not sophisticated. So you often see me not using keywords like override, final, public(while inheritance) just to make code compact & consumable(most of the time) in single standard screen size. I also prefer struct instead of class just to save line by not writing "public:" sometimes and also miss virtual destructor, constructor, copy constructor, prefix std::, deleting dynamic memory, intentionally. I also consider myself a pragmatic person who wants to convey an idea in the simplest way possible rather than the standard way or using Jargons. Note: If you stumbled here directly, then I would suggest you go through What is design pattern? first, even if it is trivial. I believe it will encourage you to explore more on this topic. All of this code you encounter in this series of articles are compiled using C++20(though I have used Modern C++ features up to C++17 in most cases). So if you don't have access to the latest compiler you can use https://wandbox.org/ which has preinstalled boost library as well. Intent To get the interface you want from the interface you have. An adapter allows two incompatible classes to work together by converting the interface of one class into an interface expected by the client/API-user without changing them. Basically, adding intermediate class i.e. Adapter. If you find yourself in a situation of using Adapter then you might be working on compatibility between libraries, modules, plugins, etc. If not then you might have serious design issues because, if you have followed Dependency Inversion Principle early in the design. Use of Adapter Design Pattern won't be the case. Adapter Design Pattern Examples in C++ Implementing an Adapter Design Pattern is easy, just determine the API you have & the API you need. Create a component which aggregates(has a reference to,...) the adaptee. Classical Adapter C++ x 32 1 struct Point { 2 int32_t m_x; 3 virtual void draw(){ cout<<"Point\n"; } 4 }; 5 6 struct Point2D : Point { 7 int32_t m_y; 8 void draw(){ cout<<"Point2D\n"; } 9 }; 10 11 void draw_point(Point &p) { 12 p.draw(); 13 } 14 15 struct Line { 16 Point2D m_start; 17 Point2D m_end; 18 void draw(){ cout<<"Line\n"; } 19 }; 20 21 struct LineAdapter : Point { 22 Line& m_line; 23 LineAdapter(Line &line) : m_line(line) {} 24 void draw(){ m_line.draw(); } 25 }; 26 27 int main() { 28 Line l; 29 LineAdapter lineAdapter(l); 30 draw_point(lineAdapter); 31 return EXIT_SUCCESS; 32 } You can also create a generic adapter by leveraging C++ template as follows: C++ xxxxxxxxxx 1 1 template 2 struct GenericLineAdapter : Point { 3 T& m_line; 4 GenericLineAdapter(T &line) : m_line(line) {} 5 void draw(){ m_line.draw(); } 6 }; The usefulness of the generic approach hopefully becomes more apparent when you consider that when you need to make other things Point-like, the non-generic approach becomes quickly very redundant. Pluggable Adapter Design Pattern using Modern C++ The Adapter should support the adaptees(which are unrelated and have different interfaces) using the same old target interface known to the client/API-user. Below example satisfy this property by using C++11's lambda function & functional header. C++ xxxxxxxxxx 1 36 1 /* Legacy code -------------------------------------------------------------- */ 2 struct Beverage { 3 virtual void getBeverage() = 0; 4 }; 5 6 struct CoffeeMaker : Beverage { 7 void Brew() { cout << "brewing coffee" << endl;} 8 void getBeverage() { Brew(); } 9 }; 10 11 void make_drink(Beverage &drink){ 12 drink.getBeverage(); // Interface already shipped & known to client 13 } 14 /* --------------------------------------------------------------------------- */ 15 16 struct JuiceMaker { // Introduced later on 17 void Squeeze() { cout << "making Juice" << endl; } 18 }; 19 20 struct Adapter : Beverage { // Making things compatible 21 function m_request; 22 23 Adapter(CoffeeMaker* cm) { m_request = [cm] ( ) { cm->Brew(); }; } 24 Adapter(JuiceMaker* jm) { m_request = [jm] ( ) { jm->Squeeze(); }; } 25 26 void getBeverage() { m_request(); } 27 }; 28 29 int main() { 30 Adapter adp1(new CoffeeMaker()); 31 make_drink(adp1); 32 33 Adapter adp2(new JuiceMaker()); 34 make_drink(adp2); 35 return EXIT_SUCCESS; 36 } The pluggable adapter sorts out which object is being plugged in at the time. Once an object has been plugged in and its methods have been assigned to the delegate objects(i.e. m_request in our case), the association lasts until another set of methods is assigned. What characterizes a pluggable adapter is that it will have constructors for each of the types that it adapts. In each of them, it does the delegate assignments (one, or more than one if there are further methods for rerouting). Pluggable adapter provides the following two main benefits: You can bind an interface(bypassing lambda function in constructor argument), unlike the object we did in the above example. This also helps when adapter & adaptee have a different number of the argument. Benefits of Adapter Design Pattern Open-Closed Principle: One advantage of the Adapter Pattern is that you don't need to change the existing class or interface. By introducing a new class, which acts as an adapter between the interface and the class, you avoid any changes to the existing code. This also limits the scope of your changes to your software component and avoids any changes and side-effects in other components or applications. By above two-point i.e. separate class(i.e. Single Responsibility Principle) for special functionality & fewer side-effects, it's obvious we do requires less maintenance, learning curve & testing. AdapterDesing Pattern also adheres to the Dependency Inversion Principle, due to which you can preserve binary compatibility between multiple releases. Summary by FAQs When to use the Adapter Design Pattern? -- Use the Adapter class when you want to use some existing class, but its interface isn't compatible with the rest of your code. -- When you want to reuse several existing subclasses that lack some common functionality that can't be added to the superclass. -- For example, let say you have a function which accepts weather object & prints temperature in Celsius. But now you need to print the temperature in Fahrenheit. In this case of an incompatible situation, you can employ the Adapter Design Pattern. Real-life & practical example of the Adapter Design Pattern? -- In STL, stack, queue & priority_queue are adaptors from deque & vector. When stack executes stack::push(), the underlying vector does vector::push_back(). -- A card reader which acts as an adapter between the memory card and a laptop. -- Your mobile & laptop charges are kind of adapter which converts standard voltage & current to the required one for your device. What are the differences between Bridge & Adapter Design Pattern? -- Adapter is commonly used with an existing app to make some otherwise-incompatible classes work together nicely. -- Bridge is usually designed up-front, letting you develop parts of an application independently of each other. What is the difference between Decorator & Adapter Design Pattern? -- Adapter converts one interface to another, without adding additional functionalities\ -- Decorator adds new functionality into an existing interface. What is the difference between Proxy & Adapter Design Pattern? -- Adapter Design Pattern translates the interface for one class into a compatible but different interface. -- Proxy provides the same but easy interface or some time act as the only wrapper.
August 25, 2020
by Vishal Chovatiya
· 13,688 Views · 5 Likes
article thumbnail
Brand New Flutter APP Publish and Update via Google PlayStore
In that article we will learn how to publish and update a brand new Flutter project to the Google Play Store.
August 25, 2020
by Omer Yilmaz
· 11,442 Views · 2 Likes
article thumbnail
Server-Side Rendering (SSR) Made Easy With Angular Universal 9+
See how to use Angular Schematic to easily perform Server-Side Rendering for improved SEO and page speed for smaller devices.
August 25, 2020
by Rohana Liyanarachchi
· 40,983 Views · 1 Like
article thumbnail
Registration Form with HTML and CSS #1
Today we are going to build a simple registration form. The requirements for this tutorial is just HTML, CSS and a code editor.As we all know,
August 25, 2020
by deji adesoga DZone Core CORE
· 33,046 Views · 1 Like
article thumbnail
Integrating VTS With JMeter
For this assignment, VTS was the only way to go since we could not provision any DB that quickly and nor could we write our own solution
Updated August 25, 2020
by Shivaram Thirunavukkarasu
· 14,892 Views · 7 Likes
  • Previous
  • ...
  • 911
  • 912
  • 913
  • 914
  • 915
  • 916
  • 917
  • 918
  • 919
  • 920
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×