Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further minimize the framework #296

Closed
9 of 15 tasks
thekid opened this issue Mar 29, 2015 · 5 comments
Closed
9 of 15 tasks

Further minimize the framework #296

thekid opened this issue Mar 29, 2015 · 5 comments

Comments

@thekid
Copy link
Member

thekid commented Mar 29, 2015

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

See comment on util below:

  • Date and time handling
  • Money and currency
  • Profiling
  • Properties
  • Command line handling

Security considerations

Speed impact

Dependencies

Related documents

@thekid
Copy link
Member Author

thekid commented Mar 29, 2015

See https://github.com/xp-forge/mirrors for what the reflection API's successor could look like

@thekid
Copy link
Member Author

thekid commented Apr 7, 2015

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)

@thekid
Copy link
Member Author

thekid commented May 31, 2015

The future of lang.types is https://github.com/xp-forge/wrappers

@thekid thekid mentioned this issue Aug 22, 2015
3 tasks
@thekid
Copy link
Member Author

thekid commented Dec 8, 2015

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

thekid added a commit to xp-framework/core that referenced this issue Dec 8, 2015
@thekid thekid mentioned this issue Dec 30, 2015
@thekid thekid mentioned this issue Jan 8, 2016
3 tasks
thekid added a commit to xp-framework/core that referenced this issue Jan 21, 2016
* xp-framework/rfc#303: THIS! IS! VERSIOOOOON
* xp-framework/rfc#307: Extract XPCLI from core
* xp-framework/rfc#301: Extract logging from core
* xp-framework/rfc#293: Extract unittest from core
* xp-framework/rfc#296: Further minimize the framework
* xp-framework/rfc#297: Rebase
@thekid thekid closed this as completed Jan 21, 2016
@thekid
Copy link
Member Author

thekid commented Jan 24, 2016

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant