Computed properties and packaging

Before we in class,Take a look at the previously mentioned "SoC" concept,We say this is called "Separation of Concerns",I translate it as separation of duties - the different sections that focus on their part。Or a target to achieve a goal。

The goal not only to make the code more modular and easier to maintain,Also let the system run more efficiently。So,We want the communication between objects becomes more standardized job。

Data Hiding

You go and see you writing framework code that, when used,Which gives you direct show[……]

Click link to continue reading...

Stored value and reference

Declare a variable

We use var to declare a variable,Congguizili like a tube placed in the experimental stage;

We give a specified variable type,Just like in the test tube labeled the;

Then put reagents must be marked on the label - otherwise could cause an explosion or poisoning。

Same,If we try to give a reservoir into a wrong data type,Then the compiler will complain - yes there is always a way to be able to fool the compiler - anyway, I will not teach you this method,That would cause it to crash。[……]

Click link to continue reading...

Guess the number game:An object of the class difference

A lesson on our first taste OOP Style,Ambiguous classes and objects in exactly what is it? This lesson we use a simple little chestnut to introduce to you。

Trying to explain

We say that the relationship between classes and objects and the relationship between the design of products,Take Our house is,Certainly there will be a corresponding building design,But the design will not only correspond to a building,At least one cell must be met with a set of drawings is not it? Our "Class" is the "design"。We use this design designed object's properties、Function and so a series of content,Then instantiating yield[……]

Click link to continue reading...

Our test environment and has shown signs of OOP

Some students did not take into account the iPhone,Swift language learning but at least we will have OS X operating system,Our code shows will be completed in OS X,Using the CLI interface。So although it looks old and was,But believe me take the GUI make you worry a lot - because that is another matter。

So now,Let's say hello and OOP

We take a look,Developing with OOP in the end is what it looks like?

We are not taking into account the high level of development,So we put all the functions of real[……]

Click link to continue reading...

How Swift 2.0 Declare an abstract class?

We all know that in Java declare an abstract class or method you want to use the abstract keyword,But unfortunately familiar things always gone,In Swift has no label。

Then,How should we declare an abstract class it?

Private constructor (initializer) Act

It actually makes a very familiar, right? Bar private constructor of that class certainly can not be initialized,Nature can not create an object instance ...... but ...... but how can there be so many,Anyway, it can be used on the line!
[crayon-677f9[……]

Click link to continue reading...

Programming Methodology Course Outline

Haha! And we met again,The ten milk to give us a newProgramming Course

This is the syllabus before programming methodology,I was very glad to do so a decision to throw in outline here:) Although the end of the course,But a separate reading this outline is a good choice,I will go back based on this update it,To accommodate the new live version of the programming methodology -

Foreword

The courses weAlreadyWith Karel This famous little robot as the breakthrough point,Karel solve the problem by teaching the process to become familiar with the programming development of thinking,Lets you quickly[……]

Click link to continue reading...

Karel introduce this robot

Early in the 1970s,Stanford University graduate Rich Pattis think if we make the novice programmer in a relatively complex programming language,,Comparatively simple learning environment,Will contribute to the programming language teaching。This simple environment characterized by a variety of programming languages ​​from abstraction。So he designed such a program environment,Allow students to teach a robot to solve simple problems。This robot is Karel,It is named after a Czech writer Karel Capek, His sci-fi drama, in its 1921 R.U.R.(Ross[……]

Click link to continue reading...

For my own use Swift 2 Wrote a rudimentary Karel Robot

Update it!

This update adds a branch,Goal is to create the "Next" function,In addition to repair the ugly side of the white block interface!

Currently no more modifications,run.swift file more refreshing,No more double thread it!

With an array of state of static storage Karel,Thanks for the banana king!

Adjust the speed of the great dream is within reach!?

 

Write the software I spent a total of 11 hours,Intermediate pit live countless times。And now I do not know why so real[……]

Click link to continue reading...

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0

When you learn Java,Some details of the small problems tend to be very confusing,When in receive parameters, for example。

If your program needs to receive arguments in order to run,And you did not give the default parameters,That can cause this error:

For example, your code is:

When you need to run the program at this point passed in the parameter。It's not difficult,The hard part is in ecl[……]

Click link to continue reading...