Prev | Current Page 273 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

In this chapter, you will learn about the
following topics:
Dividing the code into packages
Importing types from packages
Adopting libraries written by others
Using resources
Commenting the code to produce documentation
Unit testing
Writing test code
Building Reusable Code
Many type definitions can be coded in a single file. This can be useful as long as the declarations
are few and short, but this rarely happens in a real project. The solution is to divide the code into
atomic blocks that are easy to reach and identify. To this purpose, haXe implements a package
system to keep the code well organized and easy to reuse. A package is like a bucket that can
contain type definitions separated in individual files and/or sub - packages. Each definition name
must be unique in the same package.
A big advantage of packages is that they help avoid conflicting names. More than often, it happens
that classes with the same name, Point for example, are defined in the application and in an
external library used in the project.


Pages:
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285