Java programming Archives - SoftUni Global https://softuni.org/tag/java-programming/ Learn Programming and Start a Developer Job Fri, 16 Dec 2022 13:26:06 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.3 https://softuni.org/wp-content/uploads/2022/04/cropped-SoftUni-Global-Logo-Square-notext-32x32.png Java programming Archives - SoftUni Global https://softuni.org/tag/java-programming/ 32 32 Making A Sliding Puzzle in Java: Step-by-step Guide [Project Tutorials] https://softuni.org/project-tutorials/making-a-sliding-puzzle-in-java/ https://softuni.org/project-tutorials/making-a-sliding-puzzle-in-java/#respond Mon, 17 Oct 2022 13:05:04 +0000 https://softuni.org/?p=23354 In this edition of the Project Tutorial series, we will create a simple sliding puzzle game in Java.

The post Making A Sliding Puzzle in Java: Step-by-step Guide [Project Tutorials] appeared first on SoftUni Global.

]]>

Sliding puzzles are mechanical devices made of blocks of wood or plastic set into a frame as well as simple but addictive computer games that improve your problem-solving skills. The pieces are usually simple shapes or imprinted with colors, patterns, sections of a bigger picture, numbers, or letters.  Sliding puzzles, also known as sliders or sliding-block puzzles, are different from rearrangement puzzles in that the pieces cannot be lifted or removed from the frame. To win, you have to arrange them in a specific pattern by sliding them into certain routes on the board. Each move opens a new path and rearranges the pieces, so you have to plan carefully in order to achieve the end configuration.

Following this tutorial, you will make your own 3×3 sliding puzzle using Java.

Sliding-Puzzle-Gameplay

Note: To create the game, you can use more advanced implementations like arrays and matrices. The method used in this tutorial is simple and targets absolute beginners.
Let’s begin.

Before You Start

For the user interface, you use Swing. Swing is a GUI (Graphical User Interface) widget toolkit for Java. It is built on top of the AWT (Abstract Windowing Toolkit) API. Unlike AWT, Java Swing provides platform-independent and lightweight components.

The javax.swing package provides classes for the Java Swing API such as JButton, JTextField, JLabel, JMenu, etc. You will use the Main method to start the program, but the programming logic will be written in a separate class.

Preparing Variables

Create a new project and give it a descriptive and meaningful name.

Your Main method should look like this:

				
					public class Main {
   public static void main(String[] args){
       new Puzzle();
   }
}
				
			

Right-click on your project folder and create a new Java class – Puzzle. To use the functionalities (methods) of Swing, the class should extend JFrame. To make certain actions happen when you click on the puzzle pieces, you also need an event listener. Make the class implement ActionListener.

				
					import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Puzzle extends JFrame implements ActionListener{
}
				
			

Your puzzle will be 3×3 so you need to declare 9 buttons for each of the puzzle pieces, as well as a shuffle button to rearrange them. You can also implement a counter for the number of clicks the user has performed. To make the counter, you need an integer and a label to visualize the number.

				
					JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,shuffle;
int counter = 0;
JLabel counterLabel;
				
			

Creating Constructor

When you start the game, the first thing you will see is a new game window. Let’s set it up. Because the Puzzle class inherits (extends) from JFrame, it can call JFrame methods like setSize() and add(element).

				
					Puzzle(){
   setSize(400,400);
   setLayout(null);
   setVisible(true);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				
			

It is 400×400 pixels in size (which you can customize to your preference) and will close when you click the X button on the top right.

Next, you need to initialize all the elements.

				
					b1 = new JButton("1");
b2 = new JButton(" ");
b3 = new JButton("3");
b4 = new JButton("4");
b5 = new JButton("5");
b6 = new JButton("6");
b7 = new JButton("7");
b8 = new JButton("8");
b9 = new JButton("2");
shuffle = new JButton("Shuffle!");
counterLabel = new JLabel("Clicks: 0");
				
			

Then add these elements to the window and set proper bounds.

				
					add(b1);add(b2);add(b3);add(b4);add(b5);add(b6);add(b7);add(b8);add(b9); add(shuffle);
Container contentPane = this.getContentPane();
contentPane.add(counterLabel);

b1.setBounds(90,60,50,40);
b2.setBounds(160,60,50,40);
b3.setBounds(230,60,50,40);
b4.setBounds(90,115,50,40);
b5.setBounds(160,115,50,40);
b6.setBounds(230,115,50,40);
b7.setBounds(90,170,50,40);
b8.setBounds(160,170,50,40);
b9.setBounds(230,170,50,40);
shuffle.setBounds(135,245,100,40);
counterLabel.setBounds(145,15,180,40);
				
			

Now run the program. It should look like this:

Sliding-Puzzle

The next step is optional, but it will improve the visual appeal of your game. It involves changing the background color of the puzzle pieces, the font, and the font size. You can select your own or use the ones from this example.

				
					shuffle.setBackground(Color.LIGHT_GRAY);

b1.setBackground(Color.decode("#5adbb5"));
b2.setBackground(Color.decode("#5adbb5"));
b3.setBackground(Color.decode("#5adbb5"));
b4.setBackground(Color.decode("#5adbb5"));
b5.setBackground(Color.decode("#5adbb5"));
b6.setBackground(Color.decode("#5adbb5"));
b7.setBackground(Color.decode("#5adbb5"));
b8.setBackground(Color.decode("#5adbb5"));
b9.setBackground(Color.decode("#5adbb5"));

b1.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b2.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b3.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b4.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b5.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b6.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b7.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b8.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
b9.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 18));
shuffle.setFont(new Font(Font.DIALOG, Font.PLAIN, 18));
counterLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 18));

				
			

In the end, you get:

Finally, attach an action listener to every button:

				
					b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
shuffle.addActionListener(this);
}
				
			

And the Puzzle constructor is done.

Adding Action

The Action Listener is a simple event handler with only one method – actionPerformed (ActionEvent e). It is used to define what should happen when a user performs a certain operation. It registers the event of clicking a button, for example. The ActionListener is one for all buttons, so you have to make a separate if statement for each one of them in the actionPerformed method. Let’s start with the Shuffle button.

				
					public void actionPerformed(ActionEvent e){
   if(e.getSource() == shuffle){
       String s = b4.getText();
       b4.setText(b9.getText());
       b9.setText(s);
       s = b1.getText();
       b1.setText(b5.getText());
       b5.setText(s);
       s = b2.getText();
       b2.setText(b7.getText());
       b7.setText(s);
       counter = -1;
       counterLabel.setText("Clicks: 0");
   }
				
			

The logic of moving puzzle pieces is simple: instead of physically moving the pieces around the board, you simply change their text.

				
					if(e.getSource() == b1){
   String s = b1.getText();
   if(b2.getText().equals(" ")){ b2.setText(s); b1.setText(" ");}
   else if(b4.getText().equals(" ")){ b4.setText(s); b1.setText(" ");}
}
				
			

Let’s break the process into a few steps:

  1. Extract the text from the current button;
  2. Determine which of the adjacent buttons has no text;
  3. Substitute the empty text with the extracted one;
  4. Set the text of the current button to an empty string.

Follow this logic for the other pieces as well.

				
					if(e.getSource() == b2){
   String s=b2.getText();
   if(b1.getText().equals(" ")){ b1.setText(s); b2.setText(" ");}
   else if(b3.getText().equals(" ")){ b3.setText(s); b2.setText(" ");}
   else if(b5.getText().equals(" ")){ b5.setText(s); b2.setText(" ");}
}
if(e.getSource() == b3){
   String s=b3.getText();
   if(b2.getText().equals(" ")){ b2.setText(s); b3.setText(" ");}
   else if(b6.getText().equals(" ")){ b6.setText(s); b3.setText(" ");}
}
if(e.getSource() == b4){
   String s=b4.getText();
   if(b1.getText().equals(" ")){ b1.setText(s); b4.setText(" ");}
   else if(b7.getText().equals(" ")){ b7.setText(s); b4.setText(" ");}
   else if(b5.getText().equals(" ")){ b5.setText(s); b4.setText(" ");}
}
if(e.getSource() == b5){
   String s=b5.getText();
   if(b2.getText().equals(" ")){ b2.setText(s); b5.setText(" ");}
   else if(b4.getText().equals(" ")){ b4.setText(s); b5.setText(" ");}
   else if(b6.getText().equals(" ")){ b6.setText(s); b5.setText(" ");}
   else if(b8.getText().equals(" ")){ b8.setText(s); b5.setText(" ");}
}
if(e.getSource() == b6){

   String s=b6.getText();
   if(b9.getText().equals(" ")){ b9.setText(s); b6.setText(" ");}
   else if(b3.getText().equals(" ")){ b3.setText(s); b6.setText(" ");}
   else if(b5.getText().equals(" ")){ b5.setText(s); b6.setText(" ");}

}
if(e.getSource() == b7){
   String s=b7.getText();
   if(b4.getText().equals(" ")){ b4.setText(s); b7.setText(" ");}
   else if(b8.getText().equals(" ")){ b8.setText(s); b7.setText(" ");}

}
if(e.getSource() == b8){
   String s=b8.getText();
   if(b7.getText().equals(" ")){ b7.setText(s); b8.setText(" ");}
   else if(b9.getText().equals(" ")){ b9.setText(s); b8.setText(" ");}
   else if(b5.getText().equals(" ")){ b5.setText(s); b8.setText(" ");}
}

				
			

The last button marks the end of the puzzle, so it should also include a statement that checks whether it has been solved. For that to happen, the pieces must be put in the following order:
1 2 3
4 5 6
7 8 empty

Therefore, the simplest way to verify this order is to check the text on each button.

				
					if(e.getSource() == b9){
   String s=b9.getText();
   if(b6.getText().equals(" ")){ b6.setText(s); b9.setText(" ");}
   else if(b8.getText().equals(" ")){ b8.setText(s); b9.setText(" ");}

   if(b1.getText().equals("1")&&b2.getText().equals("2")&&b3.getText()
           .equals("3")&&b4.getText().equals("4")&&b5.getText().equals("5")
           &&b6.getText().equals("6")&&b7.getText().equals("7")&&b8.getText()
           .equals("8")&&b9.getText().equals(" ")){
       JOptionPane.showMessageDialog(Puzzle.this,"YOU WON!\n" + "You clicked: " + counter + " times.");
   }
}
				
			

You can add a dialog box with a custom message that will pop up when the puzzle is solved. To do that, use the JOptionPane.showMessageDialog() method.

Finally, increase the counter integer and update the label’s text to the new value at the end of the if statements.

				
					counter++;
counterLabel.setText("Clicks: " + counter);
				
			

Your sliding puzzle is ready!

Conclusion

By following this tutorial, you have programmed your own sliding puzzle in Java using simple if statements and some basic functionality of the Swing library. Explore the library’s other features and think of ways to expand your project by adding, for example, a scoreboard, an option to switch between different puzzle sizes, randomization of the shuffle, etc. And don’t forget to upload it to your GitHub profile.

To check out the final code and compare it to yours, click the link below.

If you need any help or advice, leave a comment.

Lesson Topics

In this tutorial we cover the following steps:
  • Preparing Variables
  • Creating Constructor
  • Adding Logic to Action Listener

The post Making A Sliding Puzzle in Java: Step-by-step Guide [Project Tutorials] appeared first on SoftUni Global.

]]>
https://softuni.org/project-tutorials/making-a-sliding-puzzle-in-java/feed/ 0
Java or Kotlin – What Is Better for Android Development? https://softuni.org/dev-talks/java-or-kotlin-what-is-better-for-android-development/ https://softuni.org/dev-talks/java-or-kotlin-what-is-better-for-android-development/#respond Fri, 29 Jul 2022 14:24:52 +0000 https://softuni.org/?p=22752 In this article, we examine the differences between Java and Kotlin and their strengths and weaknesses to help you make a decision when choosing a programming language for Android development.

The post Java or Kotlin – What Is Better for Android Development? appeared first on SoftUni Global.

]]>

When it comes to Android development, two of the most popular programming languages are Java and Kotlin. While Kotlin, which was released in 2011, is still being developed, Java has been around since 1995 and is open source, making it one of the most widely used languages. However, Kotlin has been taking off since 2017 when Google included it as an official Android development language along with Java.

If you’re new to Android development, the question of whether to use Kotlin or Java will probably not be on your mind at first. You will most likely opt to use Java until you become more familiar with the platform and decide what language would better suit your needs. But once you start becoming more confident with your Android development skills, choosing between Kotlin and Java will be a bit more difficult as both languages have some advantages and drawbacks, which we will examine in this article.

Java

Java is a versatile and powerful programming language that can be used for a wide range of purposes. It is platform-independent and object-oriented. Platform independency is possible since the language uses byte-code and once compiled, the code can be run on any machine irrespective of its operating system. Also, using the principles of object-oriented programming increases the flexibility and reusability of the code.

Benefits-Of-Java-Infograph

Java does not use explicit pointers. This means that developers can not access the memory directly from the code. Also, programs are executed inside the Java Virtual Machine (JVM), providing additional security to the code. If an unauthorized method tries to access a private variable, the program fails to compile and prevents the system from a crash.

Java is widely used and has a large community of developers who are continuously creating new libraries and tools to make development easier. Moreover, Android Studio, the official IDE for Android development, is based on JetBrains’ IntelliJ IDEA, which also supports Java development.

Kotlin

Kotlin is a new language developed by JetBrains. It is a statically typed programming language. Just like Java, it uses byte-code which can be executed on the JVM. It can also be compiled into JavaScript. It has intuitive, easy-to-learn syntax. 

Benefits-Of-Kotlin-Infograph

Kotlin is compatible with Java and can be used alongside existing Java code. In fact, its purpose is to interoperate with code written in Java and improve it while using Java libraries and frameworks. This leads to reducing the boilerplate code, making it simpler, easier to read and understand, and safer in terms of potential bugs. Moreover, you can write Gradle code in Kotlin, allowing you to build iOS applications.

Kotlin is concise and expressive, meaning that you can write less code to accomplish the same task. This can lead to fewer errors and a faster development process overall. An example of reducing the boilerplate code is using the Data Classes.
You can see a side-by-side comparison of code written in Java and in Kotlin on the graphic below.

Class-Definition-Java-Kotlin-Comparison

Kotlin has null safety built-in, which eliminates the risk of NullPointerException (NPE) errors since it fails to compile whenever an NPE may be thrown. It also supports higher-order functions, lambda expressions, and operator overloading, making the language a combination of functional and procedural programming.

Although it is a new language, it is gaining a lot of popularity in the development community. However, there are still some drawbacks to using Kotlin for Android development. The language is not yet as widely adopted as Java. This means that the learning resources are limited. Also, the community of Kotlin users is smaller so finding help and support, or experienced developers for your business may be more difficult. 

Conclusion

Kotlin and Java are both great options for Android development. They each have their own strengths and weaknesses that should be considered. Kotlin is a younger language, but it has many features that make it a great choice for developers. However, the concepts of Android SDK are based on Java so learning the basics might be useful. Moreover, it is still the most popular language for Android development and additional knowledge would definitely will be an advantage to you.

The answer to the question “Java or Kotlin?” depends on your preferences and what you are looking for in a programming language. One thing is certain – learning both will benefit you by expanding your tech stack and improving your coding abilities.

The post Java or Kotlin – What Is Better for Android Development? appeared first on SoftUni Global.

]]>
https://softuni.org/dev-talks/java-or-kotlin-what-is-better-for-android-development/feed/ 0
Object-Relational Mapping (ORM) [Dev Concepts #19.2] https://softuni.org/dev-concepts/object-relational-mapping-orm/ https://softuni.org/dev-concepts/object-relational-mapping-orm/#respond Mon, 13 Dec 2021 09:21:00 +0000 https://softuni.org/?p=9218 In this short video, we will get familiar with the Object-Relational Mapping concept

The post Object-Relational Mapping (ORM) [Dev Concepts #19.2] appeared first on SoftUni Global.

]]>

In this lesson, you will become familiar with the Object-Relational Mapping technologies or the so-called ORMs. As a relative newcomer to programming, terms like ORMs can sound intimidating. The nice part about them is that they allow us to write code easier once we understand them.

Object-Relational Mapping technology is the idea of writing queries using your favorite programming language. We interact with a database using our language of choice instead of SQL.

Let’s say that we have an application. An ORM will convert the result of a database query into a class within our application. The selected columns will map to the class properties. On the other hand, if you push data towards the database, an ORM will map the properties of a class into columns of a table. When people say ORM, they refer to a framework that implements this technique. Here are some of the most frequently used ORM frameworksEntity Framework, Hibernate, Sequelize, and SQLAlchemy.

Lesson Topics

In this video we review the following topics:
  • ORM Technologies
  • Overview Live Demo – ToDo List

Lesson Slides

The post Object-Relational Mapping (ORM) [Dev Concepts #19.2] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/object-relational-mapping-orm/feed/ 0
Databases: Mini Overview [Dev Concepts #19.1] https://softuni.org/dev-concepts/databases-mini-overview-19-1/ https://softuni.org/dev-concepts/databases-mini-overview-19-1/#respond Mon, 13 Dec 2021 05:30:00 +0000 https://softuni.org/?p=9264 In this lesson of the series Dev Concepts, we take a look at Databases!

The post Databases: Mini Overview [Dev Concepts #19.1] appeared first on SoftUni Global.

]]>

In this episode, Svetlin Nakov will explain to you what databases are.  That probably is not news to you, but the world creates a lot of data nowadays. By 2030, more than 465 exabytes of data will be created each day globally. That statistic is proof that handling data becomes essential, and that is where Databases come into the picture.

A database is a place for storing our data but in an organized structure.  Data is organized and stored in the form of tables. A table contains rows and columns. Each row in a table is a record, and column a field that describes the row.  For example, In a customer table, each row is a unique person, and fields like name and address describe this specific customer.

We usually say that our database is MySQL, MongoDB, SQLite, MS SQL Server, etc. That is wrong! They are not databases, but database management systems(DBMS)

The DBMS is the software that you install on your personal computer or a server, and then you would use it to manage a database. Modern software systems use a DBMS system to manage data instead of implementing the data management internally.

One of the most important DBMS are: 

  • Relational Database Management Systems (RDMS)
  • NoSQL Database Systems

Today’s demo will be done with RDMSystem. They consider the relationship between the tables by using primary keys and foreign keys. Thus, it offers an advantage over other DBMS by fetching and storing the data. It is used in enterprises for storing large amounts of data.

Examples of RDBMS are:

  • Microsoft SQL Server
  • SQLite

The next type of DBMS  is NoSQL. Non-relational databases do not store data in tables. Instead, there are multiple ways to store data in NoSQL databases, such as Key-value, Document-based, and Column-based. Each record does not have to be in the same structure as other records. Due to this, to add additional data, you can add more records without changing the structure of the entire database. Although there are many perks to NoSQL databases, SQL databases are still more commonly used at this point.

Database systems are a necessary component of most modern software systems, and software engineers must have at least basic database skills.

If you are new to programming, make sure to watch our Free Full Java Basics course! It will give you the necessary foundation to build upon and become a successful software engineer!

Lesson Topics

In this video we review the following topics:

  • Databases
    • DBMS
    • Relational Databases
    • NoSQL Databases
  • Web SQL – Example

Remember that coding is a skill, which should be practiced. To learn to code, you should write code, every day, for a long time. Watching tutorials is not enough. You should code! 

We would love to hear from you, so leave a comment below saying what topics you would like to see next. 

Lesson Slides

The post Databases: Mini Overview [Dev Concepts #19.1] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/databases-mini-overview-19-1/feed/ 0
[12/13] Java Foundations Certification: Java API Classes https://softuni.org/code-lessons/java-foundations-certification-java-api-classes/ https://softuni.org/code-lessons/java-foundations-certification-java-api-classes/#respond Thu, 09 Dec 2021 17:02:13 +0000 https://softuni.org/?p=9189 Build a strong foundation of knowledge in Java programming! Prepare for your “Java Foundations” official exam by learning some of the most commonly used Java API Classes.

The post [12/13] Java Foundations Certification: Java API Classes appeared first on SoftUni Global.

]]>

In the current lesson, we take a closer look at the most frequently used Java API classes. Svetlin Nakov will explain all about the Math class, how to generate random numbers, the need for BigInteger and BigDecimal in programming, and how to work with date and time in Java. We will also look at two of the main Java classesArrays and Formatter.

The Math class contains methods for performing basic numeric operations, such as round, min, max, abs, ceil, etc.. The Arrays class contains various methods which facilitate array manipulation. String.format() allows us to return the formatted string by given locale, format, and arguments.

In this lesson you will find many helpful examples and exercises, so make sure to practice what you’ve learned! That’s the only way to grasp the concept at hand.

BigInteger and BigDecimal are used for handling large and small numbers with great precision. BigInteger will throw an exception when the result is out of range. BigDecimal gives the user complete control over the rounding behavior. 

Importing a single package allows us to work with the date and time API.
In this lesson you will find many helpful examples and exercises, so make sure to practice what you’ve learned! 

As always, we advise you to pause the video right before the solving part of each problem and try to do the exercises on your own first. Then, if you have difficulties, just watch the provided solutions in the video. If you still have questions, we’re always here to help! 

*The exercise descriptions are to be found in the PDF document at the end of this post.

Lesson Topics

This video covers the following topics:

1. The Judge System

  • The Exception class 
  • Types of exceptions and their hierarchy

2. The Math Class

3. The Random Class

4. The Arrays Class

  • Methods of the Arrays Class 
  • Example of Sorting an Array 

5. String Formatter

6. BigInteger and BigDecimal

7. Java Date and Time

 

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Description

Lesson Slides

The post [12/13] Java Foundations Certification: Java API Classes appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-foundations-certification-java-api-classes/feed/ 0
React Native: Short Overview [Dev Concepts #18] https://softuni.org/dev-concepts/react-native-short-overview/ https://softuni.org/dev-concepts/react-native-short-overview/#respond Wed, 08 Dec 2021 09:21:42 +0000 https://softuni.org/?p=9154 Upgrade your knowledge of React with this React Native Dev Concepts lesson!

The post React Native: Short Overview [Dev Concepts #18] appeared first on SoftUni Global.

]]>

In this episode, we’ll focus on modern mobile app development, while using React Native

In the previous episode, we reviewed “React“ which is the number one web framework for 2021. Today we will be focusing on modern mobile app development technologies and React Native. 

The lesson includes a small demo React Native mobile app, which defines a JSX component and renders it in the Web browser. 

For front-end and client-side app development, mobile apps are important. To build our mobile application we need to combine development principles, concepts, platforms, technologies, frameworks, libraries, and tools. In this lesson, we will be reviewing the two major mobile app platforms that dominate the markets.

 

They are Android and ioS. Each one of them has its perks: 

  • Android devices are less expensive compared to iOS devices. They also provide more freedom and options for developers. 
  • iOS devices are slightly less popular, despite their high price. This market is more profitable because most apps follow a paid model. 

Mobile app development technologies are split into several categories: Android, iOS, and Hybrid. We have talked about the first two, but what are Hybrid technologies? They are based on JavaScript and HTML5 using an embedded Web browser. There are more mobile app dev technologies, but those are the well-known ones we will be talking about. 

Lesson Topics

In this video we review the following topics:
  • Mobile App Technologies 
  • Overview Live Demo – Summator

Lesson Slides

The post React Native: Short Overview [Dev Concepts #18] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/react-native-short-overview/feed/ 0
React: Short Overview [Dev Concepts #17] https://softuni.org/dev-concepts/react-short-overview/ https://softuni.org/dev-concepts/react-short-overview/#respond Tue, 07 Dec 2021 09:29:25 +0000 https://softuni.org/?p=9127 In this lesson of the series Dev Concepts we take a look at React!

The post React: Short Overview [Dev Concepts #17] appeared first on SoftUni Global.

]]>

In the current lesson, we will review a highly popular JavaScript UI library, called “React“. In short, React.JS is a component-based front-end technology for the Web. The JSX components in React combine HTML and JavaScript to display the component UI, which is bound to the internal component state.

The lesson includes a small demo React app, which defines a JSX component and renders it in the Web browser.

Later in the lesson, you will find a slightly more complicated demo: how to create a simple React calculator, which sums two numbers. We will review each of the files inside the sample React app to understand better how it works internally.

So, what is React?

When we talk about user interface and front-end frameworks, it is worth mentioning React.

  • React is a powerful JavaScript library from Facebook for building Web user interfaces using HTML, CSS, and JavaScript. The UI is built from JSX components, which combine HTML + JavaScript using a built-in templating engine.
  • React is а component-based UI library.
  • With React, developers create reusable UI componentswhich have a lifecycle, internal state and behavior.

It is discussable whether React is a library or a frameworkIt is maybe somewhere in between.

By adding some additional components like React Router, MobX, Redux, Flux, React Toolbox, and some others, we can turn to React into a fully-functional Web front-end framework.

Lesson Topics

In this video we review the following topics:
  • React – Overview
  • Live Demo – Summator

Lesson Slides

The post React: Short Overview [Dev Concepts #17] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/react-short-overview/feed/ 0
Desktop App with Windows Forms [Dev Concepts #16] https://softuni.org/dev-concepts/desktop-app-with-windows-forms/ https://softuni.org/dev-concepts/desktop-app-with-windows-forms/#respond Mon, 06 Dec 2021 12:37:25 +0000 https://softuni.org/?p=9097 Create a simple calculator with Windows Forms! Watch our new Dev Lesson to find out how.

The post Desktop App with Windows Forms [Dev Concepts #16] appeared first on SoftUni Global.

]]>

In this episode, you’ll learn how to create a desktop application using Windows Forms and C#.  
We will take a closer look at how GUI frameworks work with a live code example.

In programming, GUI means “graphical user interface“, which is a system to interact visually with the users through UI controls, such as forms, buttons, text boxes, and others.
In this session, we will show you a sample desktop app based on the Windows Forms GUI framework. We will build a simple calculator, which sums two numbers.

We will get familiar with the structure and the front-end part of the app: the main form, holding the UI controls. We will look at how the app is built, by extending a class from the UI framework, from a composition of components, and how event handlers are called from the framework to respond to user interactions.

The demo code is designed to run in a Windows environment, using Visual Studio and the .NET Framework. It can’t run on Mac or Linux. Sorry, this is a limitation of the Windows Forms technology.

Windows Forms is a classic software framework for the development of Desktop graphical user interface (GUI) apps for Microsoft Windows.

It is based on the .NET platform and the C# language.
Windows Forms provides a programming model and rich UI control library for building GUI apps.
Additionally, the Visual Studio IDE provides a powerful visual UI builder for Windows Forms, where developers design the user interface by dragging and dropping UI controls and configuring their properties and events. 

Windows Forms is an object-oriented framework. Your app is a “form“, which is an object-oriented classThis class inherits its functionality and behavior from a base class from the framework. Additional UI controls (such as labels, text boxes, and buttons) are added as data fields in the app classThe app UI controls are inserted into the tree of components, in the parent container.

Lesson Slides

The post Desktop App with Windows Forms [Dev Concepts #16] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/desktop-app-with-windows-forms/feed/ 0
Libraries and Frameworks: What Is the Difference? [Dev Concepts #15] https://softuni.org/dev-concepts/libraries-frameworks-difference/ https://softuni.org/dev-concepts/libraries-frameworks-difference/#respond Fri, 03 Dec 2021 11:01:40 +0000 https://softuni.org/?p=9064 Learn the difference between libraries and frameworks in this Dev Concepts lesson!

The post Libraries and Frameworks: What Is the Difference? [Dev Concepts #15] appeared first on SoftUni Global.

]]>

In this episode, we’ll be talking about UI and component libraries that provide ready-to-use UI controls and program components, and software frameworks that provide a technical foundation for developing certain types of apps. Both libraries and frameworks speed-up software development and are used every day by millions of developers, so you as a developer, should understand these concepts very well.

 

In this session we will explain the main difference between a library and a framework, which in short is the following:

  • Libraries extend your app by plugging a software component in it. They use the traditional program flow.
  • Frameworks are foundations of functionality, which developers extend to build an app. They use the “inversion of control” program flow.

Finally, we will explain the concept of “inversion of control” (IoC) and its purpose in modern software development. Svetlin Nakov will give you an example of how UI frameworks take the program execution flow and call your code through events when the user interacts with the user interface. This is an “inverted” program flow – IoC.

Lesson Topics

In this video we review the following topics:
  • User Interface and Front-end Frameworks
  • Libraries vs Frameworks
  • Inversion of Control (IoC)

Lesson Slides

The post Libraries and Frameworks: What Is the Difference? [Dev Concepts #15] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/libraries-frameworks-difference/feed/ 0
[11/13] Java Foundations Certification: Exception Handling https://softuni.org/code-lessons/java-foundations-certification-exception-handling/ https://softuni.org/code-lessons/java-foundations-certification-exception-handling/#comments Thu, 02 Dec 2021 10:21:20 +0000 https://softuni.org/?p=9024 Build a strong foundation of knowledge in Java programming! Learn all about handling exceptions in your code!

The post [11/13] Java Foundations Certification: Exception Handling appeared first on SoftUni Global.

]]>

In the current lesson, we take a close look at exception handling and why it’s important in software engineering.

What are exceptions? We’ve all seen one, there is no way to write completely bug-free code. In short an exception is a problem that arises during the execution of the program

Exceptions simplify code construction and maintenance and allow problematic situations to be processed at multiple levels.

In Java exceptions are objects. The base for all exceptions is the Throwable class – it contains information about the cause of the exception, its description, and the stack trace.

There are two types of exceptionschecked (also known as compile-time exceptions), and unchecked (also known as runtime exceptions).

Exceptions can be handled by the try-catch construction. The try-finally block is also used, especially when we want to ensure the execution of a given block of code. 

To raise an exception, we use the throw keyword. When an exception is thrown the program execution stops, and the execution travels over the stack until a matching catch block is reached to handle it. 

In this lesson you will find many helpful examples and exercises, so make sure to practice what you’ve learned! That’s the only way to grasp the concept at hand.

Lesson Topics

This video covers the following topics:

1. What are Exceptions?

  • The Exception class 
  • Types of exceptions and their hierarchy

2. Handling Exceptions

3. Raising (throwing) Exceptions

4. Best Practices

5. Creating Custom Exceptions

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Description

Lesson Slides

The post [11/13] Java Foundations Certification: Exception Handling appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-foundations-certification-exception-handling/feed/ 2
What Is Routing? [Dev Concepts #14] https://softuni.org/dev-concepts/what-is-routing/ https://softuni.org/dev-concepts/what-is-routing/#respond Wed, 01 Dec 2021 11:15:00 +0000 https://softuni.org/?p=9002 Learn all about routing in this Dev Concepts lesson!

The post What Is Routing? [Dev Concepts #14] appeared first on SoftUni Global.

]]>

In this video you will become familiar with the topic of “routing“, used for navigation in modern app development. In short, routing is the technology used to switch between different UI views (different app screens), based on changes of the current URL in the navigation bar. Routing is typically implemented through a routing library.

In this lesson, we will see how routing works in front-end apps. We will show you a sample routing library, which changes the view on the front-end, when the browser navigates to certain URL. Finally, we will demonstrate the concept of routing with a live coding example in JavaScript, so that we see how everything is done.

So, what is routing and why do we use it?

In front-end apps, routing is a technology for switching between different UI viewsbased on the changes of the current URL (holding the route).

In back-end apps, routing is a technology for switching between different server-side endpointsbased on the changes of the requested URL (holding the route).

Many front-end and back-end frameworks internally implement routing and invoke different functionality based on the URL and its components.

Routing libraries switch the view by URL like shown below.

  • This is the “home” URL: /
  • This is the “about” URL: /about
  • This is the “contact” URL: /contact

Different routes in the URL switch to different views.

This is briefly the concept of routing in Web apps.

Lesson Topics

In this video we review the following topics:

  • Overview of Routing and Routing Libraries
  • Live Demo – Navigation with Routing Library

Lesson Slides

The post What Is Routing? [Dev Concepts #14] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/what-is-routing/feed/ 0
What Is Templating Engine? [Dev Concepts #13] https://softuni.org/dev-concepts/what-is-templating-engine/ https://softuni.org/dev-concepts/what-is-templating-engine/#respond Tue, 30 Nov 2021 09:39:00 +0000 https://softuni.org/?p=8980 Learn all about templating engine in this Dev Concepts lesson!

The post What Is Templating Engine? [Dev Concepts #13] appeared first on SoftUni Global.

]]>

In this lesson, you will become familiar with the concept of “templating engines“, which render input data into output document (like HTML) through a template. We will explain how templates combine markup code with programming constructs to visualize data in a target output format.

 

Along with the slides, at the end of the lesson, we have included a live code example, so you can see how we can render an HTML-based UI with a templating engine. We will use a JSON dataset and the Handlebars templating engine in JavaScript to render the dataset as HTML document.

 

Templating engines render data as HTML or other format through a template.
This is very useful, when you want to visualize data, which comes from the server-side or from a database.
The template is written in some templating language like Razor, Handlebars or Pug.
Typically, templates combine HTML with special tags.
Templates can render variables, iterate over a collection and perform conditional checks.
You will definitely use templating engines in some form, if you work with data and visualization.

Lesson Topics

In this video we review the following topics:
  • Overview of Templating Engines
  • Live Demo – Rendering UI with a Templating Engine

Lesson Slides

The post What Is Templating Engine? [Dev Concepts #13] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/what-is-templating-engine/feed/ 0