官术网_书友最值得收藏!

  • MooTools 1.2 Beginner's Guide
  • Jacob Gube Garrick Cheung
  • 341字
  • 2021-04-01 13:33:35

Chapter 2. Writing JavaScript with MooTools

Using MooTools means you'll be coding in a web application framework that excels in object-oriented programming and JavaScript best practices. Modern development principles, such as unobtrusive JavaScript programming and object-based logic is the bread and butter of MooTools.

For example, modern development practices dictate that we separate our site's functional and behavioral layers (server-side and client-side scripts) from our site's content structural layer (HTML markup). This concept is known as unobtrusive JavaScript, and we'll delve into this best practice here in this chapter. You'll see one of the more important ways of how MooTools makes us write better JavaScript.

But we're going to be covering more than just unobtrusive JavaScript. We're going to work with classes, which is the design pattern of the entire MooTools framework.

MooTools is structured into classes. In programming, a class is simply a template of an object. A class can contain many methods or properties such as normal variables or even references to other classes and objects.

To understand how to write great MooTools code that adheres to best practices, you have to understand its fundamental structure and the concept of classes, which I must admit, can be confusing and hard to grok.

If you know another programming language, especially an object-oriented one, or a pseudo-object-oriented one like PHP (this is where I learned the concept of a class), then the stuff we'll discuss here will look very familiar to you. You can then compare and contrast the difference in syntax of classes in your particular language. As an example, for you PHP folks out there, in PHP 5, we have the __construct() function, which you'll soon see, is exactly like the initialize method of a MooTools class.

In this chapter we shall:

  • Learn how MooTools helps us write unobtrusive JavaScript
  • Work with classes by creating our own class
  • See how MooTools works by exploring a couple of classes
  • Learn about the concept of chainability by working through a simple animation example

So let's get on with it!

主站蜘蛛池模板: 泸定县| 山丹县| 阿荣旗| 武汉市| 嘉善县| 乐清市| 即墨市| 临武县| 瑞昌市| 大关县| 安顺市| 日照市| 衡水市| 阳西县| 大荔县| 驻马店市| 边坝县| 大邑县| 诏安县| 平塘县| 五原县| 防城港市| 灵丘县| 固始县| 金寨县| 卢湾区| 娱乐| 清水县| 株洲县| 怀远县| 醴陵市| 锦州市| 崇仁县| 正蓝旗| 永川市| 哈巴河县| 红桥区| 霞浦县| 同心县| 界首市| 平陆县|