GithubHelp home page GithubHelp logo

mdbs99 / james Goto Github PK

View Code? Open in Web Editor NEW
53.0 22.0 21.0 561 KB

James is a collection of object-oriented Pascal primitives for Lazarus and Delphi

License: MIT License

Pascal 98.26% C++ 1.74%
pascal object-pascal freepascal delphi james lazarus object-oriented

james's People

Contributors

fabriciofx avatar mdbs99 avatar nunopicado avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

james's Issues

Improve README

Make some improvements to the text of the README file.

James Testing unit

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.

Improve README file

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.

UUID/GUID in the interface declarations

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.

Avoid uses clause in interface section

There are some calls in uses clauses of interface section that could be moved to the implementation section, allowing better structure. Do you agree?

Clean up

  • Remove Delphi packages — for Delphi users, please use search path
  • Create core directories for src and test
  • Remove unused files

Cached Values

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

Add Constraints, Results and Informations.

Don't forget to update the post about it here.

Move IFDEF's to specialized units

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:

  1. In interface session there are no IFDEF's
  2. In implementation session could be includes files (*.inc) to each compiler or 3rd libraries
implementation

uses
  Classes, SysUtils,
  {$IFDEF lazarus}
    {$include james.fpc.md5.inc}
  {$ELSE}
    {$include james.delphi.md5.inc}
  {$ENDIF}

So, each implementation could be isolated.

Add tests

There is no unit test. That's a shame!

Primitive values

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.

DUnit compatible

Let's rename all AssertXxx methods to CheckXxx in all FPCUnit test classes to make compatible with DUnit.

New TBase64Hash class

Let's code a new class called TBase64Hash.
The concept is the same we did in TMD5Hash class here #42.

Rename some classes

We need to rename some classes:

  • from TStreamDivided to TDataDividedStream
  • from TStreamPartialFromText to TDataPartialFromTextStream

IIf interface and implementation

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 and james.files.clss

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.

Random text files to test

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".

New IDataGuid and TDataGuid

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;

Directive {$include james.inc}

Let's change the directive from {$include james.inc} to {$include ..\inc\james.inc} because the james.inc file is in another directory.

Rename all classes to use James as prefix

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".

Email Constraint class

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.*

Change TJamesTestsTemplateFile class to encapsulate the XML

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];  
    ...

Template tester

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.

7c7b15f#commitcomment-23179008

Make it compatible with Delphi 7 up to current

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.

Refactor some classes and unit names

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.

Improvements on Constraints

Rename DataConstraint to Constraint.
Rename DataConstraints to TConstraints.
Rename Checked method to Evaluate;

Create a secure TXMLComponent without NULL

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)?

Create a new IDataPack interface

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;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.