본문 바로가기

JAVA/JAVA

[ JAVA ] 자바프로그래밍 -01


[ JAVA ] 자바프로그래밍 -01 


JAVA 란 ? 

객체 지향 프로그래밍 언어. 즉, 객체 지향 프로그래밍을 하기 위한 (컴퓨터) 언어라는 말. 

JSP (Java Server Pages -  HTML 에 자바코드를 삽입하여 동적 웹 페이지 생성 프로그래밍 언어) , 자바스크립트 (JavaScript - Web에서 사용하는 스크립트 언어) 등에 사용되는 기본 객체 지향 프로그래밍 언어라고 할 수있다. 웹 뿐만아니라 자바(JDK) 환경에서 GUI 인터페이스를 구현하기위한 개발 툴킷(스윙)도 존재한다. 

우리는 JAVA 프로그래밍에 대해 공부하기에 앞서서, 객체지향 프로그래밍이 어떤 것인지부터 알아보도록 하자.


What is JAVA? An object-oriented programming language. That is, the term (computer) language for object-oriented programming. It is a basic object - oriented programming language used for JSP (Java Server Pages - dynamic web page generation programming language by inserting Java code into HTML) and JavaScript (JavaScript - scripting language used on the Web). There is also a development toolkit (Swing) for implementing GUI interfaces in the Java (JDK) environment as well as the Web. Before we learn about JAVA programming, let's look at what object-oriented programming is.

객체 지향 프로그래밍 ( Object-Oriented Programming , OOP ) 은 무엇인가? 

OPP 란, 프로그램을 어떻게 설계 하여야 하는지에 대한 일종의 개념이자 방법론 

- 대표적 객체지향 프로그래밍 언어 :  C++ , JAVA 


What is object-oriented programming (OOP)? OPP is a kind of concept of how to design a program, - Representative object-oriented programming languages: C ++, JAVA




객체지향 프로그래밍의 등장 배경

절차적 프로그래밍, 구조적 프로그래밍의 문제점 보완 및 개선 사항을 필두로하여, 이 전의 큰 덩어리에서 세부적이고 작은 것들을 해결했던 (Top-down) 프로그래밍 방식이, 작은 덩어리(객체)들의 집합들로 큰 덩어리를 만들어내는 상향식 (Bottom-up) 방법론이 나오기 시작.

초기 등장에는, 절차적 프로그래밍에 비해, 뒤떨어지는 처리능력, 이전과는 없던 방식으로 인한 이질감으로 크게 관심받지 못한 방식이였습니다. 하지만, GUI 의 등장으로 인한, 사용자와의 상호작용을 위한 이벤트 처리가 큰 이슈가 되었고, 이벤트 처리시 비동기적 처리방식이 큰 주목을 받고, 객체지향 프로그래밍의 성장이 시작되었습니다.

Background of the emergence of object-oriented programming

Top-down programming methods that have solved the details and small things from previous large chunks, with procedural programming and structural programming complements and improvements, make large chunks of sets of small chunks (objects) Bottom-up methodology begins to emerge.

In the early days, there was less interest than the procedural programming due to the poor processing power and the sense of heterogeneity caused by the way it was not before. However, due to the appearance of the GUI, event handling for user interaction has become a big issue, and asynchronous processing method has attracted a great deal of attention and eventually the growth of object oriented programming has begun.


* 절차지향 프로그래밍 (Procedural programming) : 초기에 등장한 프로그래밍 방식으로, 데이터를 순차적으로 실행하는 구조를 가지며, 데이터를 처리하는 알고리즘을 중요시하는 프로그래밍 방법론입니다. 

 그렇기때문에, 알고리즘 순서의 변경이 불가능하고, 단순한 구조를 가진 경우에는, 함수의 추가(변경)가 가능 할 수 있으나, 복잡한 구조에서는 처음부터 다시 로직을 짜는 것이 빠를 수 있습니다. (즉, 변경이 거의 불가능하다는 이야기)

 자동차 조립을 예를 들어보면, 각 순서는 하단, 중단, 상단 순서로 조립하는 로직을 가진 알고리즘이라면, 위의 경우에는, 원하던 모양의 Car 가 만들어 지겠지만, 아래와같이 상단, 하단, 중단로의 순서를 임의로 변경하였을 경우, 정상적인 결과를 보여줄 수 없는 것이다.


* Procedural programming: A programming methodology that emphasizes data-processing algorithms that have a structure that executes data sequentially in an early programming manner.  Therefore, it is not possible to change the order of algorithms and it is possible to add (change) a function if it has a simple structure, but in a complex structure, it may be quick to write the logic again from the beginning. (That is, the change is almost impossible)  For example, if you have an algorithm that has logic to assemble in the order of bottom, top, bottom, and top of the car, then in the above case, the car of the desired shape will be created, If it is changed arbitrarily, it can not show normal result.

절자척 프로그래밍의 장점은, 컴퓨터에 가까운 언어로, 빠른 데이터 처리 속도를 보장하고, 순서대로 진행되므로 코드 파악이 쉽습니다.

단점은, 위의 보기와 같이, 변경과 추가가 어려우며, 복잡한 스파게티 코드의 경우 유지보수가 어렵고, 이해하기가 어렵습니다. 

즉, 복잡하고, 대규모의 프로젝트에서는 적합하지 않은 프로그래밍이라고 볼 수 있겠습니다. 

The advantage of round-the-clock programming is that it is easy to grasp the code as it is in a language close to the computer, ensures fast data throughput, and proceeds in sequence. The disadvantage is that changes and additions are difficult, as shown above, and complex spaghetti code is difficult to maintain and difficult to understand. In other words, programming is not appropriate for complex, large-scale projects.




객체지향 프로그래밍의 주요 내용

 객체지향 프로그래밍은 예시적으로 설명한다면 휠, 창문 등과 같은 부품(객체)을 모아서, 조립을  하는 것이라 할 수 있겠다. 자동차를 만들기위해서 순서와는 관계없이, 필요한 부품들을 조립하여, 사용자가 원하는 'Car' 를 만들어 낼 수 있는 것이다. 절차적 프로그래밍처럼 순서대로 '차'를 만드는 것에 비해 느린 제작(처리)속도를 가지고 있지만, 우리가 원하는 기능만을 가진 차를 만들 수 있고, 새로운 차를 만들수도 있고, 기존의 차의 제작방법을 변경(재사용)할 수 도 있습니다.

실세계에서 각각의 사물들의 상호작용으로 인해 모든 사건들이 발생하고 존재한다. 라는 개념에서 착안한 JAVA는 '상호작용하는 객체들의 프로그래밍' 이라고 할 수 있습니다.

Main contents of object-oriented programming

 Object-oriented programming is an example of assembling parts (objects) such as wheels, windows and so on. Regardless of the order in which the car is made, it is possible to assemble the necessary parts and create the 'Car' that the user wants. As with procedural programming, we have a slower production (processing) speed than creating "cars" in order, but we can make cars with only the features we want, create new ones, (Reuse).

In the real world, all events occur and exist because of the interaction of each object. JAVA, which is based on the concept of 'programming of interacting objects' can be said.



*  자동차 부품간의 상호작용으로, 자동차 라는 사물이 생기고, 해당 사물의 동작 역시도, 부픔(객체)들의 상호작용으로 인해 동작이 가능하게 되는 것이다. 

* Interaction between automobile parts creates an automobile object, and the operation of the object also becomes possible due to the interaction of objects (objects).



객체지향 프로그래밍 특징

Object-Oriented Programming Features


1. 추상화 (Abstraction)

:  객체지향에서의 추상화는, 실세계에 존재하는 객체의 핵심적인 기능, 공통된 속성들과 기능들을의 추출하여, 클래스화 하는 것. 축구게임을 추상화를 예를들어 보면,

: Object - oriented abstraction is to extract and classify the core functions, common properties and functions of objects in the real world. If you look at an example of a football game abstraction,


 박지성, 김지성, 이지성이라는 축구선수는, 실세계에 존재하는 실제 선수(객체)입니다. 선수들은 각기 다른 이름, 키, 성별, 나이, 특기, 능력등의 신체능력에서 부터, 취미와 같은 내적인 부분도 존재합니다. 객체지향 프로그래밍에서는 축구게임에서 필요로하는 부분(변수)들을 추출하고, 축구선수의 동작(메소드)를 정의하여 Player 클래스를 완성시킵니다. 

 즉, 내가만든 객체지향 프로그램에서의 '축구선수' 를 정의하게 되는 것 입니다. 축구선수를 이용하기 위해서는 해당 Class를 상속, 호출하기만 하면, 축구선수를 표현할 수 있는 것이지요.

Soccer player Park Ji Sung, Kim Ji Sung and Lee Ji Sung are real players (objects) that exist in the real world. Players have different internalities, such as different names, keys, gender, age, skills, abilities and physical abilities, such as hobbies. In object-oriented programming, we extract the parts (variables) needed in a soccer game and define the player's actions (methods) to complete the Player class.

 That is, I define a 'football player' in my object-oriented program. To use a soccer player, simply inherit the class and call it, and you can express a soccer player.

2. 캡슐화 (Encapsulation)

: 객체의 속성(변수, DATA 필드)과 행위 (함수, Methods) 를 하나로 묶고, 실제 구현 내용은 외부에서 확인할 수 없도록 은닉하며, 접근지정자에 따라 접근 정도를 나누어 캡슐화 합니다. 

객체지향 프로그래밍에서 사용하는 접근 지정자로는, 

: It bundles the attributes (variable, DATA field) and behavior (function, method) of the object, hides the actual implementation from outside and encapsulates it according to the access specifier.

The access specifiers used in object-oriented programming include:

 Private

  자신의 클래스 내부의 메서드에서만 접근 허용

 Protected 

  자신의 클래스 내부 또는 상속받은 자식 클래스에서 접근 허용

 Public 

  모든 접근 허용


- 목적 

필드와 메소드 덩어리에 대해 무분별한 외부 접근 방지와, 피해 방지를 위함

- Goal To prevent unauthorized external access to fields and method chunks and to prevent damage


3. 상속 (Inheritance)  (재사용성)

: 실세계에서는 부모가 자식에게 물려주는 행위를 상속이라 표현하지만, 객체지향 프로그래밍에서는 자식(클래스)이 부모(클래스)를 '선택' 하여 부모의 것을 물려 받는 것을 의미합니다.


- 목적

부모 클래스의 재사용을 통해, 불필요한 코드 중복 방지, 적은 코딩라인, 유지보수의 효율성

: In the real world, the inheritance inherited by a parent is referred to as inheritance, but in object-oriented programming, a child (class) inherits the parent's (parent's) selection.

- Goal By reusing parent classes, avoid unnecessary code duplication, less coding lines, and more efficient maintenance


4. 다형성 (Polymorphism)

: 정의적인 측면에서는, 여러가지의 형태를 가진 성질 . 즉, 냉장고(부모클래스) 중에서도 김치냉장고(자식클래스) 가 존재합니다. 그런 김치냉장고에서는, 김치보관 기능뿐만아니라, 냉장고의 기능인 음료보관, 과일보관기능, 잡곡/쌀 보관기능(필자의 집 김치냉장고는 그런기능이 있습니다) 과 같은 냉장고의 기능을 가진 김치냉장고를 만들 수 있습니다. 

 객체지향에서의 다형성을 알기위해서는 오버라이딩 과 오버로딩에 대해 이해하여야 합니다.

In terms of definition, it has various forms. In other words, Kimchi refrigerator (child class) exists among refrigerator (parent class). In such a kimchi refrigerator, you can make a kimchi refrigerator that has the function of a refrigerator such as a function of a refrigerator, a beverage storage function, a fruit storage function, a grains / rice storage function (my house kimchi refrigerator has such a function) There is.

 To understand polymorphism in object orientation, we need to understand overriding and overloading.


- 오버라이딩 (Overriding)

: 자식 클래스(또는 서브클래스) 가 자신의 슈퍼클래스 (또는 부모클래스) 중 하나에 의해 이미 제공된 메소드(Method)를 특정한 형태로 구현하는 것.

 즉, 상위 클래스에서 상속받은 메소드를 하위 클래스에서 메소드를 재 정의하는 것을 오버라이딩이라 합니다. 냉장고에서의 냉장, 냉동 메소드를 김치냉장고에서는 김치냉장 기능으로 재정의할 수 있다는 것입니다.

: A child class (or subclass) implementing a method (method) already provided by one of its superclasses (or a parent class) in a specific form.  In other words, redefining a method in a subclass of a method inherited from a superclass is called overriding. The refrigeration and freezing methods in the refrigerator can be redefined as the Kimchi refrigerator function in the Kimchi refrigerator.



- 오버로딩 (Overloading)

: 오버로딩의 경우, 하나의 클래스안에서 동일한 이름의 (여러개의)메소드가 존재할수 있습니다. 이때의 각각의 메소드들은 인자의 타입이 달라야 합니다. 각자의 다른 인자의 타입으로, 서로를 구분할 수 있으며, 하나의 클래스 내부에서 동일한 이름의 메소드를 정의하는 것을 오버로딩이라 합니다.

: For overloading, there can be (several) methods of the same name in a class. Each method must have a different argument type. Different types of arguments can be distinguished from each other, and defining a method with the same name within a class is called overloading.





부족한 내용, 틀린 내용, 지적하고 싶은 부분, 공감되는 부분 

댓글 , 공감등을 통한 참여는 언제든지 환영합니다.

 지식 공유를 통해 함께 앞으로 

나아갈 수 있도록 도와주시면 감사하겠습니다. ^^


★ 공감, 광고 클릭 한번으로 저에게 큰 힘이 됩니다 ★



Inadequate content, wrong content, points to point out, part of sympathy Please feel free to participate in comments, sympathy, etc.  Forward together through knowledge sharing I would appreciate it if you could help me move forward. :)


★ Empathy, the click of an ad is a great power to me