Object Oriented Programming,OOP,面向对象编程!

面向对象编程(Object Oriented Programming,OOP,面向对象程序设计)是一种计算机编程架构。OOP 的一条基本原则是计算机程序是由单个能够起到子程序作用的单元或对象组合而成。
OOP: Object Oriented Programming,面向对象的程序设计。所谓“对象”在显式支持面向对象的语言中,一般是指类在内存中装载的实例,具有相关的成员变量和成员函数(也称为:方法)。面向对象的程序设计完全不同于传统的面向过程程序设计,它大大地降低了软件开发的难度,使编程就像搭积木一样简单,是当今电脑编程的一股势不可挡的潮流。
OOP 达到了软件工程的三个主要目标:重用性、灵活性和扩展性。为了实现整体运算,每个对象都能够接收信息、处理数据和向其它对象发送信息。

//opp面向过程编程。
//关注的是事情本身,解决问题一共分为几步,逐步完成每一个环节
//最终解决问题。
//oop面向对象编程。
//关注的重心是 参与某件事情的对象,而不是事情本身。
//面向对象的核心是如何设计这些对象。
//类:是对相同事物的抽象和提炼。
//对象:对象是类具体体现。
//类如何去形容事物呢?
//特征和行为
//特征:描述特点,称为属性。
//行为:描述功能,称为方法
//一个类包含2部分内容:特征(属性)、行为(方法)
//修饰符 class 类名{
// 修饰符 类型 属性名 [= 初始值];
//…
// 修饰符 返回值类型 方法名(参数列表){
// 方法体;
// }
//}
//有了类之后,我们就可以创建对象了。
//类型(类名) 变量名 = new 类型() ;

     package com.lanou3g.demo1;
        public class Person {
        //特征(属性)
          public String name;	//姓名
          public String sex;	//性别
          public int age;		//年龄

     //行为(方法)
public void eat() {
	//吃饭
	System.out.println("吃饭");
}
public void sleep() {
	//睡觉
	System.out.println("睡觉");
}	

public void study() {
	//学习
	System.out.println("学习");
}
}

新的类里面创建一个对象

    public class TestObject {
     public static void main(String[] args) {
	/*
	//创建一个对象。
	Person p = new Person();
	//当有了具体对象以后,我们就可以访问对象的属性以及
	//对象的方法了。
	
	//访问属性: 对象.属性
	//设置属性的值
	//把对象p的姓名设置成 张三
	p.name = "张三";//注意:值的类型必须与属性的类型一致。
	//读取属性的值
	//例如 打印 p的姓名
	System.out.println(p.name);
	
	//把p的性别设置为 男  年龄设置为22.
	p.sex = "男";
	p.age = 22;
	//打印p的 年龄和性别
	System.out.println(p.age);
	System.out.println(p.sex);
	
	//对象访问方法---对象调用方法。
	//语法格式:对象.方法名(参数);
	p.eat();
	p.sleep();
	p.study();
	
	
	
	Person p1 = new Person();
	p1.name = "李四";
	p1.age = 23;
	
	Person p2 = new Person();
	p2.name = "王五";
	*/
	
	
	Rect rect1 = new Rect();
	rect1.x = 30;
	rect1.y = 20;
	rect1.width = 20;
	rect1.height = 10;
	System.out.println(rect1.area());
	System.out.println(rect1.perimeter());
	System.out.println(rect1.isSquare());
}
}

//变量的作用域:变量起作用的区域。
//局部变量,块变量

//局部变量:在 方法内 定义的变量称为局部变量。
//作用域:从定义的那一行开始,一直到所在的方法结束。

//块变量:在 一对{}里面定义的变量。
//作用域:从定义的那一行开始,一直到所在的大括号结束。

Title: R Object-Oriented Programming Author: Kelly Black Length: 190 pages Edition: 1 Language: English Publisher: Packt Publishing Publication Date: 2014-10-23 ISBN-10: 1783986689 ISBN-13: 9781783986682 A practical guide to help you learn and understand the programming techniques necessary to exploit the full power of R About This Book Learn and understand the programming techniques necessary to solve specific problems and speed up development processes for statistical models and applications Explore the fundamentals of building objects and how they program individual aspects of larger data designs Step-by-step guide to understand how OOP can be applied to application and data models within R Who This Book Is For This book is designed for people with some experience in basic programming practices. It is also assumed that they have some basic experience using R and are familiar using the command line in an R environment. Our primary goal is to raise a beginner to a more advanced level to make him/her more comfortable creating programs and extending R to solve common problems. In Detail R is best suited to produce data and visual analytics through customizable scripts and commands, instead of typical statistical tools that provide tick boxes and drop-down menus for users. The book is divided into three parts to help you perform these steps. It starts by providing you with an overview of the basic data types, data structures, and tools available in R that are used to solve common tasks. It then moves on to offer insights and examples on object-oriented programming with R; this includes an introduction to the basic control structures available in R with examples. It also includes details on how to implement S3 and S4 classes. Finally, the book provides three detailed examples that demonstrate how to bring all of these ideas together. Table of Contents Chapter 1. Data Types Chapter 2. Organizing Data Chapter 3. Saving Data and Printing Results Chapter 4. Calculating Probabilities and Random Numbers Chapter 5. Character and String Operations Chapter 6. Converting and Defining Time Variables Chapter 7. Basic Programming Chapter 8. S3 Classes Chapter 9. S4 Classes Chapter 10. Case Study – Course Grades Chapter 11. Case Study – Simulation
Build sophisticated web applications by mastering the art of Object-Oriented Javascript About This Book Learn popular Object-Oriented programming (OOP) principles and design patterns to build robust apps Implement Object-Oriented concepts in a wide range of frontend architectures Capture objects from real-world elements and create object-oriented code that represents them Learn the latest ES6 features and how to test and debug issues with JavaScript code using various modern mechanisms Who This Book Is For JavaScript developers looking to enhance their web developments skills by learning object-oriented programming. What You Will Learn Get acquainted with the basics of JavaScript language constructs along with object-oriented programming and its application. Learn to build scalable server application in JavaScript using Node.js Generate instances in three programming languages: Python, JavaScript, and C# Work with a combination of access modifiers, prefixes, properties, fields, attributes, and local variables to encapsulate and hide data Master DOM manipulation, cross-browser strategies, and ES6 Identify and apply the most common design patterns such as Singleton, Factory, Observer, Model-View-Controller, and Mediator Patterns Design applications using a modular architecture based on SOLID principles In Detail JavaScript is the behavior, the third pillar in today's paradigm that looks at web pages as something that consists of : content (HTML), presentation (CSS), and behavior (JavaScript). Using JavaScript, you can create interactive web pages along with desktop widgets, browser, and application extensions, and other pieces of software. Object-oriented programming, which is popularly known as OOP, is basically based on the concept of objects rather than actions. The first module will help you master JavaScript and build futuristic web applications. You will start by getting acquainted with the language constructs and how to organize code easily. You develop concrete understanding of variable scoping, loops, and best practices on using types and data structures, as well as the coding style and recommended code organization patterns in JavaScript. The book will also teach you how to use arrays and objects as data structures. By the end of the book, you will understand how reactive JavaScript is going to be the new paradigm. The second module is an easy-to-follow course, which includes hands-on examples of solutions to common problems with object-oriented code. It will help to identify objects from real-life scenarios, to protect and hide data with the data encapsulation features of Python, JavaScript, and C#. You will discover the advantage of duck typing in both Python and JavaScript, while you work with interfaces and generics in C#. With a fair understanding of interfaces, multiple inheritance, and composition, you will move on to refactor existing code and to organize your source for easy maintenance and extension. The third module takes you through all the in-depth and exciting futures hidden behind the facade. You should read through this course if you want to be able to take your JavaScript skills to a new level of sophistication. Style and approach This course is a comprehensive guide where each chapter consists of best practices, constructive advice, and few easy-to-follow examples that will build up your skills as you advance through the book. Get object oriented with this course, which takes you on a journey to get acquainted with few useful hands-on tools, features, and ways to enhance your productivity using OOP techniques. It will also act as a reference guide with useful examples on resolving problems with object-oriented code in Python, JavaScript, and C#. Table of Contents Chapter 1: Javascript Primer Chapter 2: Functions, Closures, And Modules Chapter 3: Data Structures And Manipulation Chapter 4: Object-Oriented Javascript Chapter 5: Javascript Patterns Chapter 6: Testing And Debugging Chapter 7: Ecmascript 6 Chapter 8: Dom Manipulation And Events Chapter 9: Server-Side Javascript Chapter 10: Objects Everywhere Chapter 11: Classes And Instances Chapter 12: Encapsulation Of Data Chapter 13: Inheritance And Specialization Chapter 14: Interfaces, Multiple Inheritance, And Composition Chapter 15: Duck Typing And Generics Chapter 16: Organization Of Object-Oriented Code Chapter 17: Taking Full Advantage Of Object-Oriented Programming Chapter 18: Object-Oriented Javascript Chapter 19: Primitive Data Types, Arrays, Loops, And Conditions Chapter 20: Functions Chapter 21: Objects Chapter 22: Prototype Chapter 23: Inheritance Chapter 24: The Browser Environment Chapter 25: Coding And Design Patterns Chapter 26: Reserved Words Chapter 27: Built-In Functions Chapter 28: Built-In Objects Chapter 29: Regular Expressions
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值