mdbs99 / james Goto Github PK
View Code? Open in Web Editor NEWJames is a collection of object-oriented Pascal primitives for Lazarus and Delphi
License: MIT License
James is a collection of object-oriented Pascal primitives for Lazarus and Delphi
License: MIT License
Make some improvements to the text of the README file.
I've decided to move Xavier to James.
I will create a new package called James.XML
.
Rename james.data.xml.clss
to james.text.xml.clss
.
Everything that is a text should be inside james.text.* directory.
For example
Let's create a new unit to do the cross compile between FPC/Lazarus and Delphi.
We should encapsulate units that are used and test registrations.
Please, see this #56 (comment) for more information.
To make the code compatible with Delphi the mode delphi should be used.
Let's improve README file by adding some information to make the goals clear.
The inspiration is this comment here in Delphi Developer group on Facebook.
Change all DataInformation*
identifiers to use DataParam*
.
I would recommend applying an UUID/GUID to every interface declaration.
Not knowing how the end user will consume these interfaces, it's conceivable that at least some of them will use them in ways that require an UUID/GUID present.
Let's move james.testing.*
units from /test
to /src
because this unit could be used by users in other program.
There is no package test for Delphi yet.
Let's create james.tests.dpk
.
There are some calls in uses clauses of interface section that could be moved to the implementation section, allowing better structure. Do you agree?
This ticket is just for organizing, create new packages, and clean the sources.
core
directories for src
and test
We have discussed about a way to cache data or object here.
I've created this issue to we continue discussing a way to implement that without using a procedural approach.
@nunopicado thought about a Maybe object, inspired in Haskell.
I suggested Laze object in that time, but I'm not satisfied with this name yet.
We already thought about using functions/anonymous functions but this was not completely implemented in Free Pascal.
So, let's come back to scratch and think just in simple objects.
I'm thinking in a simple class called TCached
. I'll make some drafts and tests. As soon as possible I will publish my results here.
Add Constraints, Results and Informations.
Don't forget to update the post about it here.
In this unit we have the code below:
uses
Classes, SysUtils,
{$IFDEF FPC}
md5,
{$ELSE}
IdGlobal, IdHash, IdHashMessageDigest,
{$ENDIF}
Let's move all $IFDEF
from units that is part of API to another specialized units, ie, each unit that can be used by final developers should not have $IFDEF
.
I'm thinking of something like that:
implementation
uses
Classes, SysUtils,
{$IFDEF lazarus}
{$include james.fpc.md5.inc}
{$ELSE}
{$include james.delphi.md5.inc}
{$ENDIF}
So, each implementation could be isolated.
There is no unit test. That's a shame!
Let's create a new TFileAsStream
to represents a file as stream.
Let's create some classes that will represent primitives values like Integer, Currency, Text, and so on.
We should create some interfaces first like IInteger
, ICurrency
, etc. Thus, we can create the first basic implementations.
Another aproach is create just one interface IScalar<T>
similiar to this one, and implement it in each class.
We need discuss more about it.
Let's create a new James.Web.* namespace for all things related to web.
Let's rename all AssertXxx
methods to CheckXxx
in all FPCUnit test classes to make compatible with DUnit.
Let's code a new class called TBase64Hash
.
The concept is the same we did in TMD5Hash
class here #42.
Some typos to fix
The idea is to reduce conditional compilation when using it
We need to rename some classes:
TStreamDivided
to TDataDividedStream
TStreamPartialFromText
to TDataPartialFromTextStream
Let's create a IIf
interface to represents an inline condition.
The basic implementation will be TIf
class.
I've been thinking to implement that using generics like that:
var
Num: INumber;
begin
Num :=
TIf.New<INumber>(
5 > 2,
TInteger.New(5),
TInteger.New(2)
);
end;
Rename james.files
to james.io
and james.files.clss
to james.io.clss
.
Let's concentrate everything that works with input and output in these units for now.
We have a template (james.tests.template.xml
) to set all files to test.
But if the user run these tests without configure this template, the tests won't pass.
Let's create an engine to create those files if they not exists.
But first, we should to advice the user if the template wasn't find. We may tell you something like "Please copy the template file to \bin and set up with your files, if you wish".
Let's create a Interface that represents a GUID and a first class to implement it. I'll handle it.
IDataGuid = interface
function Value: TGuid;
function AsString: string;
function AsSmallString: string;
end;
TDataGuid = class(TInterfacedObject, IDataGuid)
private
FGuid: TGuid;
public
constructor Create(Guid: TGuid); reintroduce;
class function New(Guid: TGuid): IDataGuid; overload;
class function New(const Guid: string): IDataGuid; overload;
class function New(Guid: Variant): IDataGuid; overload;
class function New: IDataGuid; overload;
function Value: TGuid;
function AsString: string;
function AsSmallString: string;
end;
Let's change the directive from {$include james.inc} to {$include ..\inc\james.inc} because the james.inc file is in another directory.
The current implementation of Namespaces are not smart enough and we gain (almost) nothing using it so, we will rename all units to remove all d.o.t.s.
Remove non-ASCII in all sources and tests to make more compatible with Delphi compiler.
Write a better description about the project.
I don't like short prefixes using just 2 or 3 letters. This does not prevent (all) the collision of names problems because others libraries could use the same short prefix that you chose.
But a Lib means "specialist in something". So, instead of a class named TDataStream
, I suggest TJamesStream
and so on. That is the same as saying "the James implementation to represents a Stream".
Let's create a first constraint to check email pattern using RegExpr.
It may be implemented in james.data.constraints.clss
.
Another thing, just to organize, is move *DataConstraint(s)
interfaces/classes from james.data.*
to james.data.constraints.*
Let's change TJamesTestsTemplateFile
class to encapsulate and work at template.xml
file.
The code below should be removed from Unit tests.
Template := TXMLComponent.Create(TJamesTestsTemplateFile.New.Stream);
try
Node :=
Template
.Document
.DocumentElement
.FindNode(Self.ClassName)
.FindNode('files')
.ChildNodes
.Item[0];
...
The return value is being assumed as expected value, while the expected value is being assumed as the return value.
We need a new tester to test the template, comparing with the user template.
Sometimes we update the template but the user do not know about these changes. They need to know which the differences between the files.
The community Pascal is small, comparing with another languages like Java and C#.
So, making any lib compatible with oldest versions would be excellent because we can have more users using the same code, growing the community around the same project.
Let's use Jenkins to build this project.
Here is a start https://michalis.ii.uni.wroc.pl/jenkins/
Maybe some classes and units should be refactored.
I'm talking about classes TStream*
in unit(s) james.data.stream.*
Instead using TStream*
prefix, I can create another units more especialized like james.md5.*
, james.base64
and so on.
According with @nunopicado here 7c7b15f#commitcomment-23174376, I'll update the template file by putting the tag <files>
.
Let's correct redundant info in README. I'll handle it.
Rename DataConstraint
to Constraint
.
Rename DataConstraints
to TConstraints
.
Rename Checked
method to Evaluate
;
Use const
for all arguments of interface.
It TXMLComponent
class works with default XML libs in FPC/Lazarus.
It creates a TXMLDocument
. Sometimes (many times) its methods like FindNode
, ChildNodes
, or Item
find nothing and the code receives a NULL.
The NULL is a anti-pattern as I already said here.
Is it possible creates decorators for these objects (TDOMNode
, for exemple)?
Let's update the "How to contribute?" section in README with step by step how change and submit new modifications. I'll handle it.
This new interface IDataPack
will represent any kind of data package.
The first implementation will for XML using a new TXmlPack
class.
The methods and its usage may be like this:
var
Doc: IXMLDocument;
begin
Doc :=
TXMLDocument.Create(
TXMLPack.New
.Add('root')
.Add('items')
.Add('item')
.Add('code', 1).Up
.Add('description', 'foo').Up
.Root
.Stream
);
Doc.SaveTo('file.xml');
end;
Rename TStreamBase64
to TBase64Stream
and put it into a new unit called James.Crypto.Base64
which will implements IDataStream
.
Rename TStreamMD5
to TMD5Stream
and put it into a new unit called James.Crypto.MD5
which will implements IDataStream
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.