Further minimize the framework
thekid opened this issue · 5 comments
Scope of Change
The core of the XP7-SERIES should be reduced drastically.
Rationale
There are several modules in the XP Framework's surroundings which people might want to use. However, regarding their dependency on the still heavy-weight felt xp-framework/core makes them skip these opportunities. Therefore, the goal is to reduce the framework core to the absolute minimum size.
Functionality
Currently, the Framework's core consists of:
- The core functionality in lang.base.php
- Base classes and exceptions
- Class loading infrastructure and modules
- Type system and reflection, including annotations and generics
- Wrapper types
- I/O, Networking
- Date and time handling
- Money and currency
- Collections
- Unit test API
- Logging
- Profiling
- Properties
- Command line handling
- Regular expressions, scanners and tokenizers
- Checksums & Hashing
- Certificate
- Math support for big numbers
The smallest possible would be the core functionality, base classes and exceptions as well as class loading, and a reduced type system.
Reduced type system
The XP Framework's type system builds upon a hierarchy of the lang.Type class:
lang.Type
|-- Type::$VOID
|-- Type::$VAR
|-+ lang.Primitive
| |-- Primitive::$STRING
| |-- Primitive::$INT
| |-- Primitive::$DOUBLE
| `-- Primitive::$BOOL
|-- lang.ArrayType
|-- lang.MapType
|-- lang.FunctionType
|-- lang.WildcardType
`-- lang.XPClass
The reduced type system would provide an entry-level reference type reflection via lang.XPClass
but without member reflection and support for generics.
To access e.g. a class' methods reflectively, one would need to import the xp-framework/reflection
library and use its "reflection" extension method:
$class= $instance->type()->reflection();
foreach ($class->methods() as $method) {
// ...
}
To reflect generic types, one would again use the "reflection" entry point:
$class= $instance->type()->reflection();
if ($class->isGeneric()) {
$types= $class->genericArguments();
// ...
}
The create()
method would be moved to the xp-framework/generics
library. Its wrapping "new" statements purpose has been obsolete since XP6 and the possibility to write (new T())->member()
.
Methods removed from lang.XPClass
would be:
- getMethods(), getMethod(), hasMethod()
- getConstructor(), hasConstructor()
- getFields(), getField(), hasField()
- getConstants(), getConstant(), hasConstant()
- getInterfaces()
- getAnnotations(), getAnnotation(), hasAnnotation()
- newGenericType(), genericComponents(), genericDefinition(), genericArguments(), isGeneric()
To make it easier, the XP Framework's extension method mechanism would be extended to allow omnipresent extension methods.
Libraries extracted from core
- Wrapper types
- Collections
- Unit test API
- Logging
- Regular expressions, scanners and tokenizers
- Checksums & Hashing
- Certificate
- Math support for big numbers
- Networking
Libraries under consideration to be extracted
The io
package and it io.streams
and io.sys
subpackages:
- I/O
- Date and time handling
- Money and currency
- Profiling
- Properties
- Command line handling
Security considerations
Speed impact
Dependencies
Related documents
- https://www.dartlang.org/articles/reflection-with-mirrors/
- https://msdn.microsoft.com/en-us/library/system.type(v=vs.110).aspx
- #262 (implemented in XP 6)
- RFC #293 - Extract unittests from core
- RFC #301 - Extract logging from core
See https://github.com/xp-forge/mirrors for what the reflection API's successor could look like
Util
The util
package currently consists of a number of classes with a variety of purposes. This would most probably not be extracted as a single package but as a series of packages.
$ xp -r util
@FileSystemCL<...\xp\core\src\main\php\>
package util {
package util.cmd
package util.collections
package util.log
package util.profiling
public interface util.Comparator
public interface util.Component
public interface util.Configurable
public interface util.Filter<T>
public interface util.Observer
public interface util.PropertyAccess
public interface util.PropertySource
public interface util.Visitor
public interface util.XPIterator
public enum util.Currency
public enum util.PropertyExpansion
public enum util.TimeInterval
public abstract class util.AbstractDeferredInvokationHandler
public abstract class util.Objects
public class util.ApplicationException
public class util.Binford
public class util.Calendar
public class util.CompositeProperties
public class util.ConfigurationException
public class util.Date
public class util.DateMath
public class util.DateUtil
public class util.DeferredInitializationException
public class util.FilesystemPropertySource
public class util.Filters<T>
public class util.Hashmap
public class util.HashmapIterator
public class util.Locale
public class util.MimeType
public class util.Money
public class util.NoSuchElementException
public class util.Observable
public class util.Properties
public class util.PropertyManager
public class util.RegisteredPropertySource
public class util.ResourcePropertySource
public class util.ServiceException
public class util.ServiceNotAvailableException
public class util.TimeSpan
public class util.TimeZone
public class util.TimeZoneTransition
public class util.UUID
}
The candidates for own packages (next to the already existing subpackages) are:
- Date and time
- Properties
- Money (maybe)
The future of lang.types
is https://github.com/xp-forge/wrappers
State of libraries
6.6
The security
package has been extracted from core -> https://github.com/xp-framework/security, math
will continue to live in https://github.com/xp-framework/math
, peer.*
is inside https://github.com/xp-framework/networking and text
was split into nhttps://github.com/xp-framework/tokenize, https://github.com/xp-framework/patterns and https://github.com/xp-framework/encode
6.5
The io.collections
library is now over at https://github.com/xp-framework/io-collections, util.collections
at https://github.com/xp-framework/collections, util.log
at https://github.com/xp-framework/logging and unittest
at https://github.com/xp-framework/unittest, https://github.com/xp-framework/mocks and https://github.com/xp-framework/webtest
Quantities:
$ find src/main/php/ -name '*.class.php' | wc -l
175
(Down from 426 in XP6)
Top-level view of xp-framework/core:
$ xp mirror src/main/php/
@FileSystemCL<./src/main/php>
directory C:\tools\cygwin\home\Timm\devel\xp\core\src\main\php\ {
package io
package lang
package util
package xp
}
xp:
$ xp mirror src/main/php/xp/
@FileSystemCL<./src/main/php>
directory C:\tools\cygwin\home\Timm\devel\xp\core\src\main\php\xp\ {
package xp.runtime
package xp.xar
}
io:
$ xp mirror src/main/php/io/
@FileSystemCL<./src/main/php>
directory C:\tools\cygwin\home\Timm\devel\xp\core\src\main\php\io\ {
package io.streams
package io.sys
public interface io.Channel
public class io.ByteOrder
public class io.EncapsedStream
public class io.File
public class io.FileNotFoundException
public class io.FileUtil
public class io.Folder
public class io.FolderEntries
public class io.IOException
public class io.OperationNotSupportedException
public class io.OperationTimedOutException
public class io.Path
public class io.TempFile
}
lang:
$ xp mirror src/main/php/lang
@FileSystemCL<./src/main/php>
directory C:\tools\cygwin\home\Timm\devel\xp\core\src\main\php\lang\ {
package lang.archive
package lang.reflect
public interface lang.ClassLoadingException
public interface lang.Closeable
public interface lang.Generic
public interface lang.IClassLoader
public interface lang.Runnable
public interface lang.Value
public abstract enum lang.CommandLine
public abstract class lang.AbstractClassLoader
public abstract class lang.Enum
public class lang.ArrayType
public class lang.ClassCastException
public class lang.ClassDependencyException
public class lang.ClassFormatException
public class lang.ClassLinkageException
public class lang.ClassNotFoundException
public class lang.CloneNotSupportedException
public class lang.DynamicClassLoader
public class lang.ElementNotFoundException
public class lang.Error
public class lang.FileSystemClassLoader
public class lang.FormatException
public class lang.FunctionType
public class lang.GenericTypes
public class lang.IllegalAccessException
public class lang.IllegalArgumentException
public class lang.IllegalStateException
public class lang.IllegalThreadStateException
public class lang.IndexOutOfBoundsException
public class lang.MapType
public class lang.MethodNotImplementedException
public class lang.NullPointerException
public class lang.Object
public class lang.Primitive
public class lang.Process
public class lang.ResourceProvider
public class lang.Runtime
public class lang.RuntimeError
public class lang.RuntimeOptions
public class lang.StackTraceElement
public class lang.System
public class lang.SystemException
public class lang.SystemExit
public class lang.Thread
public class lang.Throwable
public class lang.Type
public class lang.TypeUnion
public class lang.Wildcard
public class lang.WildcardType
public class lang.XPClass
public class lang.XPException
public final class lang.ClassLoader
}
util:
$ xp mirror src/main/php/util/
@FileSystemCL<./src/main/php>
directory C:\tools\cygwin\home\Timm\devel\xp\core\src\main\php\util\ {
package util.cmd
package util.profiling
public interface util.Comparator
public interface util.Component
public interface util.Configurable
public interface util.Filter
public interface util.Observer
public interface util.PropertyAccess
public interface util.PropertySource
public interface util.Visitor
public interface util.XPIterator
public enum util.Currency
public enum util.PropertyExpansion
public enum util.TimeInterval
public abstract class util.AbstractDeferredInvokationHandler
public abstract class util.Objects
public class util.ApplicationException
public class util.Binford
public class util.Bytes
public class util.Calendar
public class util.CompositeProperties
public class util.ConfigurationException
public class util.Date
public class util.DateMath
public class util.DateUtil
public class util.DeferredInitializationException
public class util.FilesystemPropertySource
public class util.Filters
public class util.Locale
public class util.MimeType
public class util.Money
public class util.NoSuchElementException
public class util.Observable
public class util.Properties
public class util.PropertyManager
public class util.RegisteredPropertySource
public class util.ResourcePropertySource
public class util.Secret
public class util.ServiceException
public class util.ServiceNotAvailableException
public class util.TimeSpan
public class util.TimeZone
public class util.TimeZoneTransition
public class util.UUID
}