100% found this document useful (5 votes)
38 views

Buy ebook Learning JavaScript Design Patterns Addy Osmani cheap price

Design

Uploaded by

piskacshulii
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
38 views

Buy ebook Learning JavaScript Design Patterns Addy Osmani cheap price

Design

Uploaded by

piskacshulii
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Download Full ebookname - Read Now at ebookname.

com

Learning JavaScript Design Patterns Addy Osmani

https://ebookname.com/product/learning-javascript-design-
patterns-addy-osmani/

OR CLICK BUTTON

DOWLOAD EBOOK

Discover More Ebook - Explore Now at ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Learning JavaScript Design Patterns A JavaScript and React


Developer s Guide 2nd Edition Adnan Osmani

https://ebookname.com/product/learning-javascript-design-patterns-a-
javascript-and-react-developer-s-guide-2nd-edition-adnan-osmani/

ebookname.com

Pro Javascript Design Patterns 1st Edition Ross Harmes

https://ebookname.com/product/pro-javascript-design-patterns-1st-
edition-ross-harmes/

ebookname.com

Learning Python Design Patterns 2nd Edition Chetan


Giridhar

https://ebookname.com/product/learning-python-design-patterns-2nd-
edition-chetan-giridhar/

ebookname.com

The Body Politic in Roman Political Thought 1st Edition


Julia Mebane

https://ebookname.com/product/the-body-politic-in-roman-political-
thought-1st-edition-julia-mebane/

ebookname.com
Cambridge English for Nursing Pre intermediate Student s
Book with Audio CD Cambridge English For Series 1st
Edition Allum
https://ebookname.com/product/cambridge-english-for-nursing-pre-
intermediate-student-s-book-with-audio-cd-cambridge-english-for-
series-1st-edition-allum/
ebookname.com

Smart Buildings Systems for Architects Owners and Builders


James M Sinopoli

https://ebookname.com/product/smart-buildings-systems-for-architects-
owners-and-builders-james-m-sinopoli/

ebookname.com

Dietary Modulation of Cell Signaling Pathways 1st Edition


Zigang Dong

https://ebookname.com/product/dietary-modulation-of-cell-signaling-
pathways-1st-edition-zigang-dong/

ebookname.com

Global Politics 9th Edition James Ray

https://ebookname.com/product/global-politics-9th-edition-james-ray/

ebookname.com

Materials Degradation and Its Control by Surface


Engineering 3rd Edition Andrew W Batchelor

https://ebookname.com/product/materials-degradation-and-its-control-
by-surface-engineering-3rd-edition-andrew-w-batchelor/

ebookname.com
WHO Guidelines for the Management of Postpartum
Haemorrhage and Retained Placenta 1st Edition World Health
Organization
https://ebookname.com/product/who-guidelines-for-the-management-of-
postpartum-haemorrhage-and-retained-placenta-1st-edition-world-health-
organization/
ebookname.com
Learning JavaScript Design
Patterns

Addy Osmani

Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo


Learning JavaScript Design Patterns
by Addy Osmani

Copyright © 2012 Addy Osmani. All rights reserved.

Revision History for the :


2012-05-01 Early release revision 1
See http://oreilly.com/catalog/errata.csp?isbn=9781449331818 for release details.

ISBN: 978-1-449-33181-8
1335906805
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2. What is a Pattern? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
We already use patterns everyday 4

3. 'Pattern'-ity Testing, Proto-Patterns & The Rule Of Three . . . . . . . . . . . . . . . . . . . . . . 7

4. The Structure Of A Design Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5. Writing Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

6. Anti-Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

7. Categories Of Design Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15


Creational Design Patterns 15
Structural Design Patterns 16
Behavioral Design Patterns 16

8. Design Pattern Categorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17


A brief note on classes 17

9. JavaScript Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


The Creational Pattern 22
The Constructor Pattern 23
Basic Constructors 23
Constructors With Prototypes 24
The Singleton Pattern 24
The Module Pattern 27

iii
Modules 27
Object Literals 27
The Module Pattern 29
The Revealing Module Pattern 36
The Observer Pattern 37
Advantages 38
Disadvantages 39
Implementations 39
The Mediator Pattern 49
Advantages & Disadvantages 50
Mediator Vs. Observer 51
Mediator Vs. Facade 51
The Prototype Pattern 52
The Command Pattern 54
The Facade Pattern 56
The Factory Pattern 58
When To Use The Factory Pattern 59
When Not To Use The Factory Pattern 59
The Mixin Pattern 60
The Decorator Pattern 61
Subclassing 61
Decorators 63
Example 1: Basic decoration of existing object constructors with new
functionality 63
Example 2: Simply decorate objects with multiple decorators 64
Pseudo-classical decorators 65
Interfaces 65
This variation of decorators and abstract decorators 66
Implementing decorators with jQuery 69
Pros and cons of the pattern 70

10. Flyweight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Flyweight and the data layer 72
Converting code to use the Flyweight pattern 72
A Basic Factory 74
Managing the extrinsic states 74
The Flyweight pattern and the DOM 76
Example 1: Centralized event handling 76
Example 2: Using the Flyweight for Performance Gains 77

11. MV* Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79


MVC 79
Smalltalk-80 MVC 79

iv | Table of Contents
MVC For JavaScript Developers 80
Models 81
Views 82
Controllers 85
Controllers in another library (Spine.js) vs Backbone.js 86
What does MVC give us? 87
Delving deeper 88
Summary 88
MVP 88
Models, Views & Presenters 89
MVP or MVC? 90
MVC, MVP and Backbone.js 90
MVVM 92
History 92
Model 93
View 94
ViewModel 96
Recap: The View and the ViewModel 98
Recap: The ViewModel and the Model 98
Pros and Cons 98
Advantages 98
Disadvantages 98
MVVM With Looser Data-Bindings 99
MVC Vs. MVP Vs. MVVM 103
Backbone.js Vs. KnockoutJS 103
Namespacing Patterns 104
What is namespacing? 104
Advanced namespacing patterns 105
Automating nested namespacing 105
Dependency declaration pattern 107
Deep object extension 108
Namespacing Fundamentals 110
1.Single global variables 111
2. Prefix namespacing 111
3. Object literal notation 112
4. Nested namespacing 114
5. Immediately-invoked Function Expressions (IIFE)s 115
6. Namespace injection 117

12. Design Patterns in jQuery Core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


Module Pattern 121
Lazy Initialization 122
The Composite Pattern 123

Table of Contents | v
The Adapter Pattern 123
The Facade Pattern 124
The Observer Pattern 125
The Iterator Pattern 126
The Strategy Pattern 127
The Proxy Pattern 127
The Builder Pattern 128
The Prototype Pattern 128

13. Modern Modular JavaScript Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131


The Importance Of Decoupling Your Application 131
A Note On Script Loaders 132
AMD 132
A Format For Writing Modular JavaScript In The Browser 132
Getting Started With Modules 133
AMD Modules With Dojo 137
AMD Module Design Patterns (Dojo) 138
AMD Modules With jQuery 139
AMD Conclusions 141
CommonJS 141
A Module Format Optimized For The Server 141
Getting Started 141
AMD && CommonJS Competing, But Equally Valid Standards 144
Basic AMD Hybrid Format (John Hann) 145
AMD/CommonJS Universal Module Definition (Variation 2, UMDjs) 145
Extensible UMD Plugins With (Variation by myself and Thomas Davis). 146
ES Harmony 148
Modules Of The Future 148
Modules With Imports And Exports 148
Modules Loaded From Remote Sources 149
Module Loader API 150
CommonJS-like Modules For The Server 150
Classes With Constructors, Getters & Setters 150
Conclusions And Further Reading A Review 152

14. Bonus: jQuery Plugin Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


Patterns 154
Note 154
A Lightweight Start 155
Further Reading 156
“Complete” Widget Factory 157
Further Reading 159
Namespacing And Nested Namespacing 159

vi | Table of Contents
Further Reading 161
Custom Events For Pub/Sub (With The Widget factory) 161
Further Reading 162
Prototypal Inheritance With The DOM-To-Object Bridge Pattern 162
Further Reading 164
jQuery UI Widget Factory Bridge 164
Further Reading 166
jQuery Mobile Widgets With The Widget factory 167
RequireJS And The jQuery UI Widget Factory 169
Further Reading 172
Globally And Per-Call Overridable Options (Best Options Pattern) 172
Further Reading 174
A Highly Configurable And Mutable Plugin 174
Further Reading 176
UMD: AMD And CommonJS-Compatible Modules For Plugins 176
Further Reading 179
What Makes A Good Plugin Beyond Patterns? 179

15. Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

16. References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

Table of Contents | vii


Preface

Design patterns are reusable solutions to commonly occurring problems in software


design. They are both exciting and a fascinating topic to explore in any programming
language.
One reason for this is that they help us build upon the combined experience of many
developers that came before us and ensure we structure our code in an optimized way,
meeting the needs of problems we're attempting to solve.
Design patterns also provide us a common vocabulary to describe solutions. This can
be significantly simpler than describing syntax and semantics when we're attempting
to convey a way of structuring a solution in code form to others.
In this book we will explore applying both classical and modern design patterns to the
JavaScript programming language.

Target Audience
This book is targeted at professional developers wishing to improve their knowledge
of design patterns and how they can be applied to the JavaScript programming lan-
guage.
Some of the concepts covered (closures, prototypal inheritance) will assume a level of
basic prior knowledge and understanding. If you find yourself needing to read further
about these topics, a list of suggested titles is provided for convenience.
If you would like to learn how to write beautiful, structured and organized code, I
believe this is the book for you.

Acknowledgments
I will always be grateful for the talented technical reviewers who helped review and
improve this book, including those from the community at large. The knowledge and
enthusiasm they brought to the project was simply amazing. The official technical re-

ix
viewers tweets and blogs are also a regular source of both ideas and inspiration and I
wholeheartedly recommend checking them out.
• Luke Smith (http://lucassmith.name, @ls_n)
• Nicholas Zakas (http://nczonline.net, @slicknet)
• Andrée Hansson (http://andreehansson.se, @peolanha)
• Alex Sexton (http://alexsexton.com, @slexaxton)
I would also like to thank Rebecca Murphey (http://rebeccamurphey.com, @rmur-
phey) for providing the inspiration to write this book and more importantly, continue
to make it both available on GitHub and via O'Reilly.
Finally, I would like to thank my wonderful wife Ellie, for all of her support while I was
putting together this publication.

Credits
Whilst some of the patterns covered in this book were implemented based on personal
experience, many of them have been previously identified by the JavaScript community.
This work is as such the production of the combined experience of a number of devel-
opers. Similar to Stoyan Stefanov's logical approach to preventing interruption of the
narrative with credits (in JavaScript Patterns), I have listed credits and suggested reading
for any content covered in the references section.
If any articles or links have been missed in the list of references, please accept my
heartfelt apologies. If you contact me I'll be sure to update them to include you on the
list.

Reading
Whilst this book is targeted at both beginners and intermediate developers, a basic
understanding of JavaScript fundamentals is assumed. Should you wish to learn more
about the language, I am happy to recommend the following titles:
• JavaScript: The Definitive Guide by David Flanagan
• Eloquent JavaScript by Marijn Haverbeke
• JavaScript Patterns by Stoyan Stefanov
• Writing Maintainable JavaScript by Nicholas Zakas
• JavaScript: The Good Parts by Douglas Crockford

x | Preface
CHAPTER 1
Introduction

One of the most important aspects of writing maintainable code is being able to notice
the recurring themes in that code and optimize them. This is an area where knowledge
of design patterns can prove invaluable.
In the first part of this book, we will explore the history and importance of design
patterns which can really be applied to any programming language. If you're already
sold on or are familiar with this history, feel free to skip to the chapter 'What is a
Pattern?' to continue reading.
Design patterns can be traced back to the early work of a civil engineer named Chris-
topher Alexander. He would often write publications about his experience in solving
design issues and how they related to buildings and towns. One day, it occurred to
Alexander that when used time and time again, certain design constructs lead to a
desired optimal effect.
In collaboration with Sara Ishikawa and Murray Silverstein, Alexander produced a
pattern language that would help empower anyone wishing to design and build at any
scale. This was published back in 1977 in a paper titled 'A Pattern Language', which
was later released as a complete hardcover book.
Some 30 years ago, software engineers began to incorporate the principles Alexander
had written about into the first documentation about design patterns, which was to be
a guide for novice developers looking to improve their coding skills. It's important to
note that the concepts behind design patterns have actually been around in the pro-
gramming industry since its inception, albeit in a less formalized form.
One of the first and arguably most iconic formal works published on design patterns
in software engineering was a book in 1995 called Design Patterns: Elements Of Reusable
Object-Oriented Software. This was written by Erich Gamma,Richard Helm,Ralph
Johnson andJohn Vlissides - a group that became known as the Gang of Four (or GoF
for short).
The GoF's publication is considered quite instrumental to pushing the concept of de-
sign patterns further in our field as it describes a number of development techniques

1
and pitfalls as well as providing twenty-three core Object-Oriented design patterns
frequently used around the world today. We will be covering these patterns in more
detail in the section ‘Categories of Design Patterns’.
In this book, we will take a look at a number of popular JavaScript design patterns and
explore why certain patterns may be more suitable for your projects than others. Re-
member that patterns can be applied not just to vanilla JavaScript (i.e standard Java-
Script code), but also to abstracted libraries such as jQuery or dojo as well. Before we
begin, let’s look at the exact definition of a ‘pattern’ in software design.

2 | Chapter 1: Introduction
CHAPTER 2
What is a Pattern?

A pattern is a reusable solution that can be applied to commonly occurring problems


in software design - in our case - in writing JavaScript-powered applications. Another
way of looking at patterns are as templates for how you solve problems - ones which
can be used in quite a few different situations.
So, why is it important to understand patterns and be familiar with them?. Design
patterns have three main benefits:
1. Patterns are proven solutions: They provide solid approaches to solving issues
in software development using proven solutions that reflect the experience and
insights the developers that helped define and improve them bring to the pattern.
2. Patterns can be easily reused:A pattern usually reflects an out of the box solution
that can be adapted to suit your own needs. This feature makes them quite robust.
3. Patterns can be expressive:When you look at a pattern there’s generally a set
structure and ‘vocabulary’ to the solution presented that can help express rather
large solutions quite elegantly.
Patterns are not an exact solution. It’s important that we remember the role of a pattern
is merely to provide us with a solution scheme. Patterns don’t solve all design problems
nor do they replace good software designers, however, they do support them. Next
we’ll take a look at some of the other advantages patterns have to offer.
• Reusing patterns assists in preventing minor issues that can cause major
problems in the application development process.What this means is when
code is built on proven patterns, we can afford to spend less time worrying about
the structure of our code and more time focusing on the quality of our overall
solution. This is because patterns can encourage us to code in a more structured
and organized fashion avoiding the need to refactor it for cleanliness purposes in
the future.
• Patterns can provide generalized solutions which are documented in a fash-
ion that doesn't require them to be tied to a specific problem. This generalized
approach means that regardless of the application (and in many cases the pro-

3
gramming language) you are working with, design patterns can be applied to im-
prove the structure of your code.
• Certain patterns can actually decrease the overall file-size footprint of your
code by avoiding repetition.By encouraging developers to look more closely at
their solutions for areas where instant reductions in repetition can be made, e.g.
reducing the number of functions performing similar processes in favor of a single
generalized function, the overall size of your codebase can be decreased.
• Patterns add to a developers vocabulary, which makes communication
faster.
• Patterns that are frequently used can be improved over time by harnessing
the collective experiences other developers using those patterns contribute
back to the design pattern community. In some cases this leads to the creation
of entirely new design patterns whilst in others it can lead to the provision of im-
proved guidelines on how specific patterns can be best used. This can ensure that
pattern-based solutions continue to become more robust than ad-hoc solutions
may be.

We already use patterns everyday


To understand how useful patterns can be, let's review a very simple element selection
problem that the jQuery library solves for us everyday.
If we imagine that we have a script where for each DOM element on a page with class
"foo" we want to increment a counter, what's the simplest efficient way to query for
the list we need?. Well, there are a few different ways this problem could be tackled:
1. Select all of the elements in the page and then store them. Next, filter this list and
use regular expressions (or another means) to only store those with the class "foo".
2. Use a modern native browser feature such as querySelectorAll() to select all of
the elements with the class "foo".
3. Use a native feature such as getElementsByClassName() to similarly get back the
desired list.
So, which of these is the fastest?. You might be interested to know that it's actually
number 3. by a factor of 8-10 times the alternatives. In a real-world application however,
3. will not work in versions of Internet Explorer below 9 and thus it's necessary to use
1. where 3. isn't supported.
Developers using jQuery don't have to worry about this problem, as it's luckily ab-
stracted away for us. The library opts for the most optimal approach to selecting ele-
ments depending on what your browser supports.
Core internally uses a number of different design patterns, the most frequent one
being a facade. This provides a simple set of abstracted interfaces (e.g $el.css(),
$el.animate()) to several more complex underlying bodies of code.

4 | Chapter 2: What is a Pattern?


We're probably all also familiar with jQuery's $('selector'). This is significantly more
easy to use for selecting HTML elements on a page versus having to manually handle
opt for getElementById(), getElementsByClassName(), getElementByTagName and so on.
Although we know that querySelectorAll() attempts to solve this problem, compare
the effort involved in using jQuery's facade interfaces vs. selecting the most optimal
selection paths ourselves. There's no contest! abstractions using patterns can offer real-
world value.
We'll be looking at this and more design patterns later on in the book.

We already use patterns everyday | 5


CHAPTER 3
'Pattern'-ity Testing, Proto-Patterns &
The Rule Of Three

Remember that not every algorithm, best-practice or solution represents what might
be considered a complete pattern. There may be a few key ingredients here that are
missing and the pattern community is generally weary of something claiming to be one
unless it has been heavily vetted. Even if something is presented to us which appears
to meet the criteria for a pattern, it should not be considered one until it has undergone
suitable periods of scrutiny and testing by others.
Looking back upon the work by Alexander once more, he claims that a pattern should
both be a process and a ‘thing’. This definition is obtuse on purpose as he follows by
saying that it is the process should create the ‘thing’. This is a reason why patterns
generally focus on addressing a visually identifiable structure i.e you should be able to
visually depict (or draw) a picture representing the structure that placing the pattern
into practice results in.
In studying design patterns, you may come across the term ‘proto-pattern’ quite fre-
quently. What is this? Well, a pattern that has not yet been known to pass the ‘pattern’-
ity tests is usually referred to as a proto-pattern. Proto-patterns may result from the
work of someone that has established a particular solution that is worthy of sharing
with the community, but may not have yet had the opportunity to have been vetted
heavily due to its very young age.
Alternatively, the individual(s) sharing the pattern may not have the time or interest of
going through the ‘pattern’-ity process and might release a short description of their
proto-pattern instead. Brief descriptions or snippets of this type of pattern are known
as patlets.
The work involved in fully documenting a qualified pattern can be quite daunting.
Looking back at some of the earliest work in the field of design patterns, a pattern may
be considered ‘good’ if it does the following:

7
• Solves a particular problem: Patterns are not supposed to just capture principles
or strategies. They need to capture solutions. This is one of the most essential
ingredients for a good pattern.
• The solution to this problem cannot be obvious: You can often find that prob-
lem-solving techniques attempt to derive from well-known first principles. The
best design patterns usually provide solutions to problems indirectly - this is con-
sidered a necessary approach for the most challenging problems related to design.
• The concept described must have been proven: Design patterns require proof
that they function as described and without this proof the design cannot be seri-
ously considered. If a pattern is highly speculative in nature, only the brave may
attempt to use it.
• It must describe a relationship: In some cases it may appear that a pattern de-
scribes a type of module. Although an implementation may appear this way, the
official description of the pattern must describe much deeper system structures
and mechanisms that explain its relationship to code.
We would be forgiven for thinking that a proto-pattern which fails to meet guidelines
isn't worth learning from, however, this is far from the truth. Many proto-patterns are
actually quite good. I’m not saying that all proto-patterns are worth looking at, but
there are quite a few useful ones in the wild that could assist you with future projects.
Use best judgment with the above list in mind and you’ll be fine in your selection
process.
One of the additional requirements for a pattern to be valid is that they display some
recurring phenomenon. This is often something that can be qualified in at least three
key areas, referred to as the rule of three. To show recurrence using this rule, one must
demonstrate:
1. Fitness of purpose - how is the pattern considered successful?
2. Usefulness- why is the pattern considered successful?
3. Applicability - is the design worthy of being a pattern because it has wider ap-
plicability? If so, this needs to be explained.When reviewing or defining a pattern,
it is important to keep the above in mind.

8 | Chapter 3: 'Pattern'-ity Testing, Proto-Patterns & The Rule Of Three


CHAPTER 4
The Structure Of A Design Pattern

You may be curious about how a pattern author might approach outlining structure,
implementation and purpose of a new pattern. Traditionally, a pattern is initially be
presented in the form of a rule that establishes a relationship between:
• A context
• A system of forces that arises in that context and
• A configuration that allows these forces to resolve themselves in context
With this in mind, lets now take a look at a summary of the component elements for
a design pattern. A design pattern should have a:
• Pattern name and a description
• Context outline – the contexts in which the pattern is effective in responding to
the users needs.
• Problem statement – a statement of the problem being addressed so we can un-
derstand the intent of the pattern.
• Solution – a description of how the user’s problem is being solved in an under-
standable list of steps and perceptions.
• Design – a description of the pattern’s design and in particular, the user’s behavior
in interacting with it
• Implementation– a guide to how the pattern would be implemented
• Illustrations – a visual representation of classes in the pattern (e.g. a diagram))
• Examples – an implementation of the pattern in a minimal form
• Co-requisites – what other patterns may be needed to support use of the pattern
being described?
• Relations – what patterns does this pattern resemble? does it closely mimic any
others?
• Known usage – is the pattern being used in the ‘wild’?. If so, where and how?
• Discussions – the team or author’s thoughts on the exciting benefits of the pattern

9
Design patterns are quite a powerful approach to getting all of the developers in an
organization or team on the same page when creating or maintaining solutions. If you
or your company ever consider working on your own pattern, remember that although
they may have a heavy initial cost in the planning and write-up phases, the value re-
turned from that investment can be quite worth it. Always research thoroughly before
working on new patterns however, as you may find it more beneficial to use or build
on top of existing proven patterns than starting afresh.

10 | Chapter 4: The Structure Of A Design Pattern


CHAPTER 5
Writing Design Patterns

Although this book is aimed at those new to design patterns, a fundamental under-
standing of how a design pattern is written can offer you a number of useful benefits.
For starters, you can gain a deeper appreciation for the reasoning behind a pattern being
needed. You can also learn how to tell if a pattern (or proto-pattern) is up to scratch
when reviewing it for your own needs.
Writing good patterns is a challenging task. Patterns not only need to provide a sub-
stantial quantity of reference material for end-users (such as the items found in the
structure section above), but they also need to be able to defend why they are necessary.
If you’ve already read the previous section on ‘what’ a pattern is, you may think that
this in itself should help you identify patterns when you see them in the wild. This is
actually quite the opposite - you can’t always tell if a piece of code you’re inspecting
follows a pattern.
When looking at a body of code that you think may be using a pattern, you might write
down some of the aspects of the code that you believe falls under a particular existing
pattern.In many cases of pattern-analysis you’ll find that you’re just looking at code
that follows good principles and design practices that could happen to overlap with the
rules for a pattern by accident. Remember - solutions in which neither interactions nor
defined rules appear are not patterns.
If you’re interested in venturing down the path of writing your own design patterns I
recommend learning from others who have already been through the process and done
it well. Spend time absorbing the information from a number of different design pattern
descriptions and books and take in what’s meaningful to you - this will help you ac-
complish the goals you have laid out for yours. Explore structure and semantics - this
can be done by examining the interactions and context of the patterns you are interested
in so you can identify the principles that assist in organizing those patterns together in
useful configurations.
Once you’ve exposed yourself to a wealth of information on pattern literature, you may
wish to begin your pattern using an existing format and see if you can brainstorm new
ideas for improving it or integrating your ideas in there. An example of someone that

11
did this is in recent years is Christian Heilmann, who took the existing module pattern
and made some fundamentally useful changes to it to create the revealing module pat-
tern (this is one of the patterns covered later in this book).
If you would like to try your hand at writing a design pattern (even if just for the learning
experience of going through the process), the tips I have for doing so would be as
follows:
• Bear in mind practicability: Ensure that your pattern describes proven solutions
to recurring problems rather than just speculative solutions which haven’t been
qualified.
• Ensure that you draw upon best practices: The design decisions you make
should be based on principles you derive from an understanding of best-practices.
• Your design patterns should be transparent to the user: Design patterns should
be entirely transparent to any type of user-experience. They are primarily there to
serve the developers using them and should not force changes to behavior in the
user-experience that would not be incurred without the use of a pattern.
• Remember that originality is not key in pattern design: When writing a pattern,
you do not need to be the original discoverer of the solutions being documented
nor do you have to worry about your design overlapping with minor pieces of other
patterns.If your design is strong enough to have broad useful applicability, it has
a chance of being recognized as a proper pattern
• Know the differences between patterns and design: A design pattern generally
draws from proven best practice and serves as a model for a designer to create a
solution. The role of the pattern is to give designers guidance to make the best design
choices so they can cater to the needs of their users.
• Your pattern needs to have a strong set of examples: A good pattern description
needs to be followed by an equally strong set of examples demonstrating the suc-
cessful application of your pattern. To show broad usage, examples that exhibit
good design principles are ideal.
Pattern writing is a careful balance between creating a design that is general, specific
and above all, useful. Try to ensure that if writing a pattern you cover the widest possible
areas of application and you should be fine. I hope that this brief introduction to writing
patterns has given you some insights that will assist your learning process for the next
sections of this book.

12 | Chapter 5: Writing Design Patterns


CHAPTER 6
Anti-Patterns

If we consider that a pattern represents a best-practice, an anti-pattern represents a


lesson that has been learned. The term anti-patterns was coined in 1995 by Andrew
Koenig in the November C++ Report that year, inspired by the GoF's book Design
Patterns. In Koenig’s report, there are two notions of anti-patterns that are presented.
Anti-Patterns:
• Describe abad solution to a particular problem which resulted in a bad situation
occurring
• Describe how to get out of said situation and how to go from there to a good
solution
On this topic, Alexander writes about the difficulties in achieving a good balance be-
tween good design structure and good context:
“These notes are about the process of design; the process of inventing physical things which
display a new physical order, organization, form, in response to function.…every design
problem begins with an effort to achieve fitness between two entities: the form in question
and its context. The form is the solution to the problem; the context defines the problem”.
While it’s quite important to be aware of design patterns, it can be equally important
to understand anti-patterns. Let us qualify the reason behind this. When creating an
application, a project’s life-cycle begins with construction however once you’ve got the
initial release done, it needs to be maintained. The quality of a final solution will either
be good or bad, depending on the level of skill and time the team have invested in it.
Here good and bad are considered in context - a ‘perfect’ design may qualify as an anti-
pattern if applied in the wrong context.
The bigger challenges happen after an application has hit production and is ready to
go into maintenance mode. A developer working on such a system who hasn’t worked
on the application before may introduce a bad design into the project by accident. If
said bad practices are created as anti-patterns, they allow developers a means to rec-
ognize these in advance so that they can avoid common mistakes that can occur - this

13
is parallel to the way in which design patterns provide us with a way to recognize
common techniques that are useful.
To summarize, an anti-pattern is a bad design that is worthy of documenting. Examples
of anti-patterns in JavaScript are the following:
• Polluting the global namespace by defining a large number of variables in the global
context
• Passing strings rather than functions to either setTimeout or setInterval as this
triggers the use of eval() internally.
• Modifying the Object class prototype (this is a particularly bad anti-pattern)
• Using JavaScript in an inline form as this is inflexible
• The use of document.write where native DOM alternatives such as document.cre-
ateElement are more appropriate. document.write has been grossly misused over
the years and has quite a few disadvantages including that if it's executed after the
page has been loaded it can actually overwrite the page you're on, whilst docu-
ment.createElement does not. You can see here for a live example of this in action.
It also doesn't work with XHTML which is another reason opting for more DOM-
friendly methods such as document.createElement is favorable.
Knowledge of anti-patterns is critical for success. Once you are able to recognize such
anti-patterns, you will be able to refactor your code to negate them so that the overall
quality of your solutions improves instantly.

14 | Chapter 6: Anti-Patterns
Random documents with unrelated
content Scribd suggests to you:
generale, intimamente vero, per la sorte di tutte le discipline
dell’intelletto: «L’arte, della quale parliamo non è amica del riposo e
della pace, non ama la probità e la moderazione..... Essa è figlia
della licenza, che gli stolti chiamano libertà, è compagna e ispiratrice
dei rivolgimenti pubblici: senza rispetti, incapace di servire, ribelle,
temeraria, arrogante, tale da non poter fiorire in una città bene
ordinata..... La vegetazione più vigorosa è figlia della terra, che non
ha mai subìto l’aratro...» [877].
SOMMARIO

INTRODUZIONE pag. 5

CAPITOLO I. — Gli imperatori di casa


Giulio-Claudia e l’istruzione nell’Impero
Romano (30 a. C. — 68 d. C.) 11

I. La politica scolastica degli Imperatori di


casa Giulio-Claudia. I privilegi di Augusto ai
praeceptores. Una scuola di Stato per la
nuova aristocrazia imperiale — II. Le
biblioteche pubbliche augustee. — III. Il
governo di Augusto e la custodia delle
opere d’arte. — IV. Augusto e l’immunità dai
carichi pubblici ai medici e ai docenti di
medicina. — V. Augusto e la nuova
educazione della gioventù. — VI.
Contenuto religioso e morale di questa
educazione. — VII. Augusto istituisce un
ufficio di sovrintendenza generale su
l’istruzione e l’educazione della gioventù
romana. — VIII. Augusto e l’istruzione
pubblica nelle provincie: la biblioteca del
Sebasteum; l’impero assume
l’amministrazione e la direzione del Museo
alessandrino. — IX. L’istruzione pubblica e
il governo centrale da Augusto a Nerone.
Caligola e i concorsi di eloquenza. Il
Museum Claudium. — X. La Corte e la sua
influenza sulla nuova aristocrazia. I
concorsi di eloquenza istituiti da Nerone e
l’incremento degli studi di retorica. Il
governo di Nerone e gli studi di filosofia. —
XI. Le immunità agli insegnanti datano
probabilmente da Nerone. — XII. Rassegna
e ampiezza di queste immunità. — XIII.
Casi di immunità speciali a favore degli
insegnanti primarii. — XIV. Nerone e
l’ellenizzarsi della educazione fisica in
Roma. — XV. Nerone e l’incremento
dell’istruzione musicale. XVI. — I
successori di Augusto e le organizzazioni
giovanili a Roma e in Italia. — XVII. Nerone
ricompone le biblioteche perite nell’incendio
del 64. — XVIII. Gli imperatori di casa
Giulio-Claudia e gli studii di giurisprudenza.
— XIX. Il nuovo regime e l’istruzione
pubblica.

CAPITOLO II. — Gl’imperatori di casa


Flavia e l’istruzione nell’Impero romano
(69-96) 81

I. Vespasiano e la fondazione di nuove


biblioteche. Riconferma delle immunità ai
maestri di grammatica, di retorica e di
filosofia. Stipendio ai principali insegnanti di
retorica in Roma. Non si tratta di una
statizzazione delle scuole di retorica. — II.
Motivi della innovazione. Condizioni
economiche dei maestri di retorica. Il
provvedimento di Vespasiano quale misura
della considerazione sociale dei retori. —
III. Trascuranza del governo imperiale verso
i grammatici e gli insegnanti elementari;
loro condizioni economiche. — IV. Rapporti
amministrativi e giuridici dei retori
stipendiati con lo Stato. Giudizio dei
contemporanei. — V. Quintiliano primo
retore stipendiato, come maestro e come
pedagogista. — VI. Tito rimane fedele alla
politica scolastica del padre. Domiziano
riedifica le biblioteche distrutte. La
ripercussione della operosità imperiale sulla
diffusione e sul regime delle biblioteche. —
VII. Domiziano inaugura nuovi concorsi di
eloquenza. — VIII. Domiziano e il trionfo
della educazione fisica a tipo ellenico.
Vespasiano, Domiziano e l’istruzione
musicale. Il nuovo indirizzo dei collegi
giovanili. — IX. Il rovescio della medaglia:
Vespasiano contro le scuole filosofiche
ateniesi. — X. Il governo dei Flavii e
l’istruzione pubblica nell’impero romano.

CAPITOLO III. Gli imperatori da Nerva a M.


Aurelio e l’istruzione pubblica
nell’Impero romano (96-180) 113

I. Reazione di Nerva e di Traiano alla politica


dei Flavii; gli stipendi ai retori interrotti;
esitanze nella riconferma delle immunità. —
II. Reazione all’educazione fisica e
musicale ellenizzante. — III. La biblioteca
Ulpia Traiana. — IV. I pueri alimentarii e i
provvedimenti relativi in Roma, in Italia e
nelle province. — V. Traiano e i maestri;
rifiorimento della coltura. — VI. P. Elio
Adriano — VII. Adriano, le immunità, gli
onori e i benefici largiti ai maestri. — VIII.
L’Athenaeum e la biblioteca Capitolina.
Adriano e gli studii di giurisprudenza. — IX.
Adriano e l’istruzione pubblica nelle
provincie: in Atene; riforme nella scuola
degli Epicurei; innovazioni nel Museo
alessandrino. — X. Le nuove norme di
Antonino Pio circa le immunità dei maestri.
— XI. Antonino Pio non inaugura scuole di
Stato in provincia, ma vi promuove
l’istituzione di scuole municipali di retorica e
di filosofia. — XII. Marco Aurelio e la
fondazione delle prime cattedre imperiali
universitarie in Atene. — XIII. I concorsi
universitarii. — XIV. Le cattedre di
fondazione imperiale nell’Athenaeum
romano. — XV. Gli Antonini, le istituzioni
alimentari e la istruzione primaria. — XVI.
Gli imperatori da Traiano a Marco Aurelio e
l’istruzione musicale. — XVII. Il governo ed
i collegi giovanili. La cura delle belle arti.
L’amministrazione delle biblioteche. L’età
degli imperatori da Nerva a Traiano, la
scuola e la coltura nell’impero romano.

CAPITOLO IV. — Lo Stato e l’istruzione


pubblica da Commodo all’abdicazione di
Diocleziano (180-305) 177

I. La cultura e l’istruzione pubblica in questo


periodo — II. Il nuovo carattere militare dei
collegia iuvenum sotto i Severi. — III. La
nuova legislazione a tutela dei maestri e
degli studenti. Il governo centrale e
l’istruzione pubblica nei comuni. — IV. Le
nuove istituzioni scolastiche di Alessandro
Severo. — V. La decadenza delle istituzioni
alimentari nel III. secolo. La politica del
governo e l’istruzione pubblica da
Alessandro Severo a Diocleziano. La
imposta municipalizzazione delle scuole di
Antiochia. — VI. Diocleziano e
l’insegnamento del diritto. L’editto de pretiis
rerum venalium e gli onorari degli
insegnanti. — VII. La soppressione delle
cattedre di astrologia. La distruzione delle
biblioteche cristiane. — VIII. Costanzo
Cloro e l’istruzione pubblica nelle Gallie. Le
Gallie nel III. e nel IV. secolo. La nomina del
retore Eumenio in Augustodunum.

CAPITOLO V. — L’istruzione pubblica


nell’Impero romano, Costantino il
Grande e i suoi figli (312-361) 211

I. La monarchia Dioclezianea-Costantiniana e
il trasporto della capitale a Costantinopoli.
Ripercussione di ciò sulle sorti della
istruzione pubblica nell’impero. — II.
Costantino e la coltura. L’Università
Costantinopolitana. — III. Una nuova
biblioteca pubblica. Costantino e l’istruzione
professionale. L’istruzione primaria; fine
delle fondazioni alimentari. — IV. Privilegi e
garanzie ai docenti privati e pubblici nelle
città di provincia. Ampliamento delle
immunità e suoi motivi. Immunità ai
professionisti delle arti edilizie e industriali.
— V. Costantino e la cura delle opere
d’arte. — VI. I figli di Costantino ne
continuano la politica; gl’imperatori, il
Senato e i governatori nella scelta dei
maestri. Riforme nell’Università ateniese.
Dichiarazione dei nuovi criterii di governo in
fatto di istruzione pubblica. — VII. I figli di
Costantino e probabile limitazione delle
immunità.

CAPITOLO VI. — Le innovazioni


scolastiche di Giuliano l’Apostata (361-
363) 239

I. Giuliano e gli atti più notevoli della sua


legislazione scolastica. Reintegrazione
dell’antica larghezza di immunità; sua
bibliofilia. La legge del 362 su
l’insegnamento pubblico e privato. — II.
L’editto su l’insegnamento classico. Un
secondo editto? — III. Giudizio sulla legge
del 362. Gli antichi e l’editto; l’approvazione
dei cristiani intransigenti; la
disapprovazione dei cristiani moderati, dei
pagani e degli indifferenti. — IV. Giudizio
dei moderni. — V. Il merito e la portata
dell’editto. — VI. L’applicazione e gli effetti.
— VII. Disegni di nuove scuole e di riforme
a vantaggio dell’istruzione classica e
musicale. Giuliano e il favore accordato ai
retori e ai filosofi. Il valore dell’opera dei
Costantiniani nei rispetti della istruzione
pubblica.

CAPITOLO VII. — La dinastia Valentiniana


e l’istruzione pubblica nell’Impero
romano (364-383) 281
I. La reazione alla politica scolastica di
Giuliano. — II. Un regolamento disciplinare
per gli studenti stranieri in Roma — III.
Valentiniano riconferma le immunità; nuove
immunità ai maestri di pittura. — IV. Valente
e la biblioteca costantinopolitana; Valente
contro l’astrologia; distruzione di opere
scientifiche classiche; giudizio che di lui fa
Temistio. — V. Le riforme scolastiche di
Graziano; l’ordinamento delle scuole in
Gallia; gli stipendii dei maestri. — VI.
Valentiniano, Graziano e i medici di Roma e
della Corte; la cura dei monumenti antichi e
delle opere d’arte. — VII. La rinascita
intellettuale in tutto l’impero.

CAPITOLO VIII. — La dinastia dei Teodosii


e la pubblica istruzione (383-450) 309

I. La reazione cattolica di Teodosio I. e


l’istruzione pubblica: la soppressione degli
stipendi ai docenti pubblici in Roma e in
Atene. — II. Eccezioni a favore dei medici;
cura delle opere d’arte. Ripresa della
decadenza intellettuale del III. secolo. — III.
I due figli di Teodosio continuano la politica
del padre. — IV. Teodosio II. riconferma le
immunità ai maestri. I provvedimenti di
Teodosio relativi alla Università
costantinopolitana. — V. Carattere di
quest’opera. L’Università costantinopolitana
e quella ateniese. La distribuzione delle
cattedre. L’abolizione dell’insegnamento
privato-pubblico. — VI. Il nuovo
ordinamento e le altre scuole medie e
superiori, creato dallo Stato. — VII.
Teodosio conferma di nuovo le immunità ai
maestri. La compilazione del Codex
Theodosianus; la scienza e l’insegnamento
giuridico.

CAPITOLO IX. — L’impero e l’istruzione


pubblica dalla morte di Teodosio II. alla
fine del governo di Giustiniano (450-565) 337

I. Necessità di estendere il presente studio


fino al VI. secolo. — II. Il governo di
Teodorico, la cultura e l’istruzione pubblica
in Italia. — III. Prosecuzione della politica di
Teodorico sotto Atalarico e Teodato,
Atalarico e le scuole di Roma. Rinascita
intellettuale. — IV. Giustiniano, la sua
reazione cristiana, e il divieto
d’insegnamento ai pagani. — V.
Soppressione dell’Università ateniese. —
VI. Sospensione degli stipendi ai docenti di
arti liberali. — VII. La compilazione del
Codex iustinianeus, del Digestum e delle
Institutiones. — VIII. Scopi e vantaggi di
tale opera rispetto alla scuola e
all’insegnamento. Riduzione delle scuole di
giurisprudenza dell’impero; aumento del
personale insegnante in Costantinopoli e in
Berito; immunità ai professori di
giurisprudenza; prolungamento del corso; la
disciplina degli studenti. — IX. I nuovi
programmi per l’insegnamento della
giurisprudenza. — X. Giustiniano e
l’istruzione pubblica negli ultimi anni del suo
governo.
CONCLUSIONE 379

I. La politica scolastica della repubblica e


dello impero. Il governo centrale e le scuole
di Stato. — II. Il governo e le scuole
municipali e private. — III. Lo Stato, i
maestri, gli studenti, la libertà
dell’insegnamento. — IV. Lo Stato e
gl’insegnamenti professionali. — V. Le
biblioteche pubbliche e loro
amministrazione. VI. Lo Stato, le
accademie, i musei; la cura delle opere
d’arte. — VII. L’imperatore, il senato, e la
suprema direzione dell’istruzione pubblica.
— VIII. L’amministrazione centrale e
provinciale. — IX. Gli impulsi indiretti del
governo alla istruzione pubblica; il tentativo
di una educazione di Stato; l’educazione
fisica. — X. La decadenza intellettuale e la
vanità effettiva dell’opera dello Stato.
INDICE ANALITICO — ALFABETICO

A censibus, 31; 32-33; (V. Census).


Adriano, A. e l’istruzione pubblica in genere, 124-126; 127; A. e le
immunità agl’insegnanti, 49-50; 50 sgg.; conferisce stipendii agli
insegnanti di Roma e delle province, 129-130; fissa per loro dei limiti
di età e delle pensioni, 127-128; 130; costruisce in Roma un edifizio
per il pubblico insegnamento, 130 sgg.; fonda la Biblioteca
Capitolina, 133; A. e lo studio del diritto, 133-135; A. fonda un
Ginnasio in Atene, 136; A. e la scuola Epicurea di Atene, 136-137;
A. e il Museo alessandrino, 138-139.
Agone capitolino, 103; 105; 106-107.
Agrippa (M. V.), Suo amore per la coltura, 19; esorta l’aristocrazia
romana ad aprire al pubblico i suoi Musei e le sue pinacoteche, 20.
Agricola, e l’istruzione pubblica in Britannia, 5.
Alessandria, Scuole di medicina, 22; di musica, 275; di
giurisprudenza, 365; il Museo di A. 34 sgg.; 131; 138-139; il Museo
Claudio, 39 sgg.; il Sebasteum, 34.
Alessandro Severo, Sua coltura, 187-188; fonda in Roma cattedre
di grammatica, medicina, aruspicina, astrologia, ingegneria,
architettura, 188-191; 390-391; erige in Roma nuovi edifici scolastici,
191; istituisce borse di studio per gli alunni poveri, 191; A. S. e le
istituzioni alimentari, 192.
Alimentari (Istituzioni), (V. Pueri alimentarii).
Annonae (borse di studio), 191; 275; 403; (V. Stipendi).
Antiochia, Scuole di A., 193.
Antiquarii, (V. Librarii).
Antonini, Gli A., e le istituzioni alimentari, 165-167; e l’istruzione
musicale, 167-170; e i collegia iuvenum, 170; e la cura delle opere
d’arte, 171-173; gli A. e l’insegnamento medio-superiore, 163-165; la
politica scolastica degli A., 174-175; (V. Antonino Pio; Marco
Aurelio; Caracalla).
Antonino Pio, e le immunità agli insegnanti, 50 sgg.; 140 sgg.; e
l’insegnamento municipale, 150-152; 385; e la cura delle opere
d’arte, 171-173; e il governo delle biblioteche, 173-174.
Architetti, 188, n. 2; 196; immunità agli A., 226; 230; Architecti
magistri (professori di architettura) e loro onorario, 196-197.
Architettura, Scuole di A. in Roma, 188; 188, n. 2; 390; 391; in
Africa, 220-221; professori di A. (V. Architecti magistri).
Areopago, L’A. ateniese e l’istruzione pubblica, 158, n. 1; 159.
Aruspicina, L’A. e la politica romana, 189; Scuole di A. in Roma,
188; 390-391.
Asia Minore, Scuole di medicina, 22.
Astrologia, L’A. e la politica romana, 188-189; Settimio Severo e
l’A., 189; pene contro l’esercizio dell’A., 188-189; Alessandro Severo
e l’A., 189-190; scuole di A. in Roma, 188; 390-391.
A Studiis, 30 sgg.; 400.
Atalarico, Sua politica scolastica, 345-348; A. e le scuole di Roma,
346 sgg.
Atene, Scuole di medicina, 22; 190; di astronomia e di astrologia,
190; le scuole filosofiche di A. e Vespasiano, 108-110; Adriano e la
Scuola Epicurea, 136-138; locali scolastici universitari, 130-131;
Adriano fonda in A. una biblioteca e un Ginnasio, 136; M. Aurelio vi
fonda cattedre di retorica e di filosofia, 153-156; A. e Costantino,
215; l’Università di A. nel IV. secolo di C., 232-233; Giuliano e
l’Università di A., 276; Teodosio I. e l’Università di A., 213;
L’Università di A. e quella di Costantinopoli, 323 sgg.; fine
dell’Università di A., 353-357.
Athenaeum, 130-133; 135; l’A. sotto gli Antonini, 162-163; l’A. e
Teodosio I., 312-313; e Teodosio II., 329-331; e Teodorico, 343.
Attila, e l’insegnamento del gotico in Italia, 338, n. 1.
Augusto, Privilegi concessi ai maestri, 12-13; fonda in Roma una
scuola per la nuova aristocrazia dell’impero, 14-16; fonda le
biblioteche Palatina e Ottaviana, 16-18; fa aprire al pubblico taluni
privati Musei e Pinacoteche, 18-21; A. e le immunità ai medici, 21-
22; e i collegia iuvenum, 23 sgg.; e l’a studiis, 30 sgg.; e l’istruzione
pubblica nelle province, 34 sgg.; e il Museo alessandrino, 37-38; e
l’arte musicale, 67; A. patenta dei ius respondentes, 76.
Augustodunum Autun, Scuole, 5; 204; 205; 208; 386.
Aurelio (Marco), Sua fede nella efficacia della scuola, 152-153;
fonda cattedre di retorica, 153-156; norme pei concorsi alle cattedre
di filosofia e di retorica in Atene, 157-162.
Ausonio, 302; 305.
Belle Arti, Augusto e la cura dello opere d’arte, 18-21; gli Antonini,
171-173; Costantino, 228-229; magistrati preposti alla cura delle
opere d’arte, 395-396; il Senato e le B. A., 397; (V. Valentiniano I;
Onorio; Arcadio; Teodorico; Comitiva romana; Curator
statuarum; Procuratores; Vicarii; Duces; Praefectvs).
Berito, Scuole, 195; sede ufficiale per l’insegnamento della
giurisprudenza, 364; 382; numero dei professori di giurisprudenza,
360-366.
Biblioteche, G. Cesare e le B. pubbliche, 16; Asinio Pollione rende
pubblica la sua B., 16; Augusto e le B. romane, 16 sgg.; la Palatina,
16-17; 73; la Ottaviana, 17; 101; la B. del Sebasteum, 34-35; del
Museo alessandrino, 35; del Nuovo Tempio di Augusto, 39; 73; la B.
Domus Tiberianae, 39, n. 1; 73; le B. pubbliche e le scuole di
giurisprudenza, 77-78; Biblioteca Pacis, 82; Domiziano fa ricostruire
le B. romane incendiate, 101; le B. municipali e private dopo
Domiziano, 101-102; il servizio interno delle B., 102; Traiano fonda
la B. Ulpia-Traiana, 119-120; Adriano fonda la B. Capitolina in Roma
e una B. pubblica in Atene, 133; 136; distruzione delle B. cristiane
nel 303, 199 sgg.; B. di Costantinopoli, 219; 231; 295-296; B. privata
di Giuliano in Costantipoli, 240; B. generali e speciali, 392;
Personale delle B., 173-174; 392-394; le B. private sulla fine del IV.
secolo di C., 316; B. imperiali private, 393 e n. 4; le B. pubbliche e il
Praefectus Urbi, 402.
Borse di studio, (V. Annonae).
Burdigala (Bordeaux), I professori delle scuole di B., 6; loro
condizioni economiche, 302.
Calculatores, 195; 195, n. 4; 196.
Caligola, istituisce a Lione un concorso di eloquenza, 39; protegge
l’arte musicale, 67; patenta dei ius respondentes, 76.
Capitolina (Biblioteca), 133.
Caracalla, Sua educazione ginnico-militare, 182; suo mecenatismo
verso le compagnie drammatiche, 179; brucia i libri di Aristotile ed
esclude gli Aristotelici dal Museo Alessandrino, 180; C. e le
immunità, 181; 184; e le istituzioni alimentari, 192.
Cassiodoro, 341; 345; 349.
Census, a censibus, 31; 32-33; magister C., 286.
Centurio rerum nitentium, 229.
Ceromatitae, 195; 196.
Cesare (C. G.), La politica scolastica di C., 12-13; C. e la prima idea
delle pubbliche biblioteche in R., 16.
Cesarea, Scuole di giurisprudenza, 365.
Cirene, scuole di medicina, 22.
Claudio, e l’a studiis, 31; 33; il Museum Claudium, 39 sgg.; C.
protegge l’arte musicale, 67.
Codex Gregorianus, 332.
Codex Hermogenianus, 332-333.
Codice Giustinianeo, 362; 366.
Codice teodosiano, 334-336.
Collegia Iuvenum, sotto Augusto, 23 sgg.; da Augusto a Nerone,
70; nel Lazio, 70-71; sotto Nerone, 71-72; sotto Domiziano, 107-108;
nel II. secolo di C., 170; nel III. secolo, 181-183; sono istituti pubblici,
404-405; i C. I. e le autorità municipali e militari, 405; (V. Magistri).
Comitiva romana, 344-345.
Comitiva primi ordinis, 322; 329-330.
Commodo, C. e le immunità degli insegnanti, 50 sgg.; istituisce
nuovi concorsi musicali, 179; rinnova i Iuvenalia, 179-180; C. e le
istituzioni alimentari, 191-192.
Concorsi, di eloquenza, 39; 103-104; di poesia e musica, 43-44;
67-69; 103-104; 179; C. per l’insegnamento superiore, 157-162; i C.
e le autorità provinciali, 159; 403.
Conditionales, 296.
Consigli Municipali, I C. M. e la nomina degli insegnanti, 159; 159,
n. 2; 241; 250; 283; 381; 385; e la concessione delle immunità agli
insegnanti, 146; 183-184; e le spese per l’istruzione pubblica, 186-
187; e il governo delle scuole, 187; 385-386; I C. M. responsabili
degli stipendii non pagati agli insegnanti, 187.
Cornuto (A.), Sua scuola, 46.
Costante, C. e Proeresio, 230; C. elargisce l’immunità agli
ingegneri, architetti etc., 230.
Costantiniani, Gl’imperatori C. e l’istruzione pubblica, 229 sgg.;
probabile limitazione delle immunità degli insegnanti, 236-237.
Costantino, e l’istruzione pubblica, 211 sgg.; fonda l’Università
Costantinopolitana, 216-217; fonda una biblioteca pubblica in
Costantinopoli, 219; C. e gl’insegnamenti professionali, 220; 226-
228; abolisce le istituzioni alimentari, 221-222; C. e le immunità degli
insegnanti, 222-228; e le belle arti, 228-229.
Costantinopoli, La fondazione di C. e l’istruzione pubblica, 211-
212; 213-214; l’Ottagono, 216-217; l’Università, 217-219; 320 sgg.;
323-326; la biblioteca pubblica, 219; 231; C. sede ufficiale
dell’insegnamento della giurisprudenza, 364.
Costanzo Cloro, nomina Eumenio professore di retorica ad
Augustodunum, 204; 205; C. C. e l’istruzione pubblica, 205-208.
Costanzo II., e Proeresio, 230; C. largisce l’immunità agli ingegneri,
architetti etc. 230; rifornisce la biblioteca di Costantinopoli, 231; sue
dichiarazioni circa i doveri dello Stato verso l’istruzione pubblica,
233-235.
Cristiani, Gli insegnanti C. e Giuliano, 243; 247; 248; 268-270; i
giovani C. e Giuliano, 248-249; 270-271; giudizii dei C. su l’editto di
Giuliano circa l’insegnamento classico, 251-252; i giovani C. e le
scuole pagane, 270-271.
Curator statuarum, 229.
Didio Giuliano, e le istituzioni alimentari, 192.
Diocleziano, e le scuole di Berito, 195; e gli onorari e gli stipendi
degli insegnanti, 195-198; D. sopprime le cattedre di astrologia e di
aruspicina di Roma, 198; D. e i libri egiziani di alchimia, 198-199;
distrugge le biblioteche cristiane, 199 sgg.; chiama a Nicomedia il
grammatico Flavio e il retore Lattanzio, 204.
Domiziano, e Quintiliano, 100; fa ricostruire le biblioteche romane
incendiate, 101; istituisce in Roma l’Agone capitolino, 103-104;
istituisce in Albano dei concorsi oratorii e poetici, 104; promuove
l’educazione fisica a tipo greco, 104-105; D. e l’istruzione musicale,
106-107; D. e i collegi giovanili, 107-108.
Donne, Le D. e l’educazione fisica al tempo di Nerone, 65; e
l’istruzione musicale, 69; Le D. possono aspirare all’insegnamento,
160.
Diritto, (V. Giurisprudenza).
Duces, I D. e la cura delle belle arti, 396; e il regime dell’istruzione
pubblica, 402-403.
Educazione fisica, in Roma e in Grecia, 62-63; l’E. f. e Nerone, 63
sgg.; l’E. f. sotto i Flavii, 104-105; nel III. secolo di C., 180; 181-182;
(V. Palaestrici; Ceromatitae).
Eliogabalo, e l’a studiis, 31.
Epicurei, La scuola filosofica degli E. e Vespasiano, 109-110; e
Adriano, 136-137.
Eumenio, E. magister memoriae di Costanzo Cloro, 204; professore
di retorica ad Augustodunum, 204; 205; Suo stipendio, 208-209;
389.
Filosofia, Insegnanti di F. in Roma, 45-46; incremento degli studii di
F. sotto Nerone, 45-46; sotto M. Aurelio, 43; le scuole di F. in Atene,
108-110; 136-138; 155-156; 325; 354; concessione dello immunità
agl’insegnanti di F., 185; gli insegnanti di F. e il diritto a ricorso, 186;
Valentiniano I. e gli insegnanti di F., 284-285.
Flavii, Gli imperatori F. e la loro politica scolastica, 110-112.
Gallerie, (V. Musei; Pinacoteche).
Gallie, (V. Augustodunum; Burdigala; Lione; Marsiglia;
Treviri); Scuole nelle G., 5; 204; Ordinamento dato da Graziano
all’istruzione pubblica nelle G., 298 sgg.; 386.
Gallieno, e la filosofia, 180.
Geometrae, (V. Matematici).
Ginnasio, Il G. di Nerone, 64; di Traiano, 118; di Adriano in Atene,
136.
Ginnastica, (V. Educazione fisica).
Giuliano, e le immunità degli insegnanti, 236-237; 240; G. fonda
una biblioteca imperiale privata in Costantinopoli, 240; sua legge
circa l’insegnamento pubblico e privato, 241-244; 250-251; 387; suo
editto circa l’insegnamento classico, 244 sgg.; 259 sgg.; giudizi degli
antichi e dei moderni su l’editto, 251-258; nessun divieto ai giovani
cristiani di apprendere le lettere greche e latine, 248-249;
conseguenze dell’editto, 267 sgg.; disegni di G. per la propaganda
dell’Ellenismo, 273-274; G. e le scuole di musica, 274-275; G. e i
maestri, 276-279; la politica scolastica di G., 279-280.
Giulio-Claudii, Gl’imperatori G. C. e la loro politica scolastica, 78-
80.
Giurisprudenza, Insegnamento della G. nella repubblica romana,
74-75; 77; l’insegnamento della G. e gl’imperatori Giulio-Claudii, 76
sgg.; scuole di G., 74; 75-77; gli studii di G. nel I. secolo di C., 76-77;
Adriano e di studii di G., 133-135; lo studio della G. sotto Commodo
e Diocleziano, 179; nel III. secolo di C., 183; immunità ai professori
di G. in Roma, 184-185; i professori di G. esclusi dal diritto di
ricorrere per compensi mancati, 186; studenti di G. in Berito, 195; le
fonti del diritto nella repubblica e nell’impero, 331-333; collezioni
giuridiche, 333 sgg.; 361-363; la G. nel IV. secolo, 333-334; nei sec.
V.-VI., 370-372; riforme di Giustiniano nelle scuole di G., 363-376.
Giustiniano, Carattere del suo governo, 350-351; politica religiosa,
351-353; politica scolastica, 339-340; 352-353; 376-378; G.
sopprime l’Università ateniese, 353-357; riduce le scuole municipali
dell’impero, e ne incamera le rendite, 357-361; G. e le collezioni
giuridiche del VI. secolo, 361-363; G. e l’insegnamento della
giurisprudenza, 363 sgg.
Gordiano I., rinnova i Juvenalia, 180.
Grammatici, (V. Insegnanti secondari; Grammatica; Immunità;
Scuole).
Grammatica, Scuole di G. in Roma, 13; 188; l’Ateneo romano e
l’insegnamento della G. 132; cattedre di G. nell’Università
costantinopolitana, 218; 325.
Graziano, e l’istruzione pubblica nelle Gallie, 298 sgg.; 386; G. e i
medici di R. 303; e la cura delle opere d’arte, 304-305.
Gregorio di Nazianzo (S.), 256; 256, n. 2; 269; 271; 273; 274; 306.
Immunità agli insegnanti secondari e superiori, 47 sgg., ai medici,
21-23; 49; 222-223; 240; 303; 320; Vespasiano, Adriano, e le I., 49-
50; Antonino Pio limita le I. degli insegnanti, 140 sgg.; le I. nel III.
secolo di C., 183-185; Costantino e le I., 222 sgg.; I. ai professionisti
di arti meccaniche, 226-228; agli ingegneri etc., 230; riduzione delle
I. dei maestri sotto i figli di Costantino, 236-237; Giuliano e le I., 240;
Valentiniano I. e le I., 290; I. ai maestri di pittura africani, 290-294;
Teodosio I. limita di nuovo le I. degli insegnanti, 311-312; Teodosio II.
riconferma le I. degli insegnanti, 319-320; I. ai professori di
giurisprudenza, 366-367; chi conferisce le I. 397; 398-399; I. del
ἱεράσθαι, 224; 398, n. 2; chi garentisce l’osservanza delle I., 401-
402; 402-403.
Imperatore, Poteri dell’I. nel campo della istruzione pubblica, 397-
399.
Impero, La politica scolastica dell’I. romano, 379-381; l’I. romano e
le scuole di Stato, 381-383; e le scuole elementari, 382-383; e le
scuole medie e superiori comunali, 385-386; e l’istruzione privata,
386-388; e l’istruzione scientifica e professionale, 390-391; l’I. e i
maestri e i discepoli, 388-389; e la coltura in genere, 404; e
l’educazione fisica, 405; l’I. non ha una speciale amministrazione per
l’istruzione pubblica, 399 sgg. (V. a Studiis); suo metodo di
amministrare le cose relative all’istruzione pubblica, 400-403.
Ingegneri (Mechanici), 188, n. 2.
Ingegneria, Scuole di I. in Roma, 188; 188, n. 2; immunità agli
ingegneri (mechanici), 230.
Insegnamento, I. professionale, (V. Librarii; Notarii;
Calculatores; Matematici; Astrologia; Aruspicina; Pittura;
Professionisti; Scuole professionali); Libertà d’I., 384-385; 389.
Insegnanti, privilegiati da Augusto, 12-13; onorati da Traiano, 123-
124; onorati e beneficati da Adriano, 127-130; autorizzati a ricorrere
contro i compensi mancati, 185-186; 187; gli I. pubblici e privati e
Teodosio II., 321-322; 326-328; onorificenze agli I., 322 (V.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like