Data Transformation Pipeline

I have create some kind of data pipeline to transform coordinate data into more useful information.

Here is the shell of pipeline:

public class PositionPipeline
{
    protected List<IPipelineComponent> components;

    public PositionPipeline()
    {
        components = new List<IPipelineComponent>();
    }

    public PositionPipelineEntity Process(Position position)
    {
        foreach (var component in components)
        {
            position = component.Execute(position);
        }

        return position;
    }

    public PositionPipeline RegisterComponent(IPipelineComponent component)
    {
        components.Add(component);
        return this;
    }
}

Every IPipelineComponent accepts and returns the same type – a PositionPipelineEntity. Code:

public interface IPipelineComponent
{
    PositionPipelineEntity Execute(PositionPipelineEntity position);
}

The PositionPipelineEntity needs to have many properties, many which are unused in certain components and required in others. Some properties will also have become redundant at the end of the pipeline.

For example, these components could be executed:

  1. TransformCoordinatesComponent: Parse the raw coordinate data into a Coordinate type.
  2. DetermineCountryComponent: Determine and stores country code.
  3. DetermineOnRoadComponent: Determine and store whether coordinate is on a road.

Code:

pipeline
    .RegisterComponent(new TransformCoordinatesComponent())
    .RegisterComponent(new DetermineCountryComponent())
    .RegisterComponent(new DetermineOnRoadComponent());

pipeline.Process(positionPipelineEntity);

The PositionPipelineEntity type:

public class PositionPipelineEntity
{
    // Only relevant to the TransformCoordinatesComponent 
    public decimal RawCoordinateLatitude { get; set; }

    // Only relevant to the TransformCoordinatesComponent 
    public decimal RawCoordinateLongitude { get; set; }

    // Required by all components after TransformCoordinatesComponent 
    public Coordinate CoordinateLatitude { get; set; }

    // Required by all components after TransformCoordinatesComponent 
    public Coordinate CoordinateLongitude { get; set; }

    // Set in DetermineCountryComponent, not required anywhere.  
    // Requires CoordinateLatitude and CoordinateLongitude (TransformCoordinatesComponent)
    public string CountryCode { get; set; }

    // Set in DetermineOnRoadComponent, not required anywhere.  
    // Requires CoordinateLatitude and CoordinateLongitude (TransformCoordinatesComponent)
    public bool OnRoad { get; set; }
}

Problems:

  • I’m very concerned about the dependency that a component has on properties. The way to solve this would be to create specific types for each component. The problem then is that I cannot chain them together like this.

  • The other problem is the order of components in the pipeline matters. There is some dependency. The current structure does not provide any static or runtime checking for such a thing.

Any feedback would be appreciated.

It appears to me as though your problem here might be partly that your pipeline is a little too abstract. It’s important to work with abstractions, but the openness of the design you have is making it hard for you to visualise the solution.

For example, with the order of components, you probably want to split these out in the pipeline, so that

pipeline
.RegisterComponent(new TransformCoordinatesComponent())
.RegisterComponent(new DetermineCountryComponent())
.RegisterComponent(new DetermineOnRoadComponent());

Might become something like

pipeline.TransformationCoordinates.Register(new TransformCoordinatesComponent());
pipeline.Determinations.Register(new DetermineCountryComponent());
pipeline.Determinations.Register(new DetermineOnRoadComponent());

Then your granularity becomes that of the number of different types of ordered component you need to have, so the Pipeline can have zero or many TransformationCoordinate components, Determination components and so on and will run all the ones available in order. Of course, this might be hidden inside pipeline.RegisterComponent splitting them out by interface, but this is an easier way to illustrate what I mean.

As you become less abstract you lose flexibility, in this case you would need to have a new collection if you added a new ordered type, so if you wanted to have an InvertComponent that ran between the TransformationCoordinate and the Determination components you would have to change your Pipeline accordingly. This is probably not a terrible thing, as long as your architecture is generally solid, however – you are likely to have to make the jump from the theoretical to the pragmatic at some point anyway.

Once you know the different component types you can guarantee that you have the correct properties available for each stage in the process- you could either ensure that the properties are set at each step on a type that always has them available or you could return a new object from each stage with the properties needed for the next.

Either way, I think you will find your work is easier if you start to think in more concrete terms about the exact processes you need to follow.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Data Transformation Pipeline

I have create some kind of data pipeline to transform coordinate data into more useful information.

Here is the shell of pipeline:

public class PositionPipeline
{
    protected List<IPipelineComponent> components;

    public PositionPipeline()
    {
        components = new List<IPipelineComponent>();
    }

    public PositionPipelineEntity Process(Position position)
    {
        foreach (var component in components)
        {
            position = component.Execute(position);
        }

        return position;
    }

    public PositionPipeline RegisterComponent(IPipelineComponent component)
    {
        components.Add(component);
        return this;
    }
}

Every IPipelineComponent accepts and returns the same type – a PositionPipelineEntity. Code:

public interface IPipelineComponent
{
    PositionPipelineEntity Execute(PositionPipelineEntity position);
}

The PositionPipelineEntity needs to have many properties, many which are unused in certain components and required in others. Some properties will also have become redundant at the end of the pipeline.

For example, these components could be executed:

  1. TransformCoordinatesComponent: Parse the raw coordinate data into a Coordinate type.
  2. DetermineCountryComponent: Determine and stores country code.
  3. DetermineOnRoadComponent: Determine and store whether coordinate is on a road.

Code:

pipeline
    .RegisterComponent(new TransformCoordinatesComponent())
    .RegisterComponent(new DetermineCountryComponent())
    .RegisterComponent(new DetermineOnRoadComponent());

pipeline.Process(positionPipelineEntity);

The PositionPipelineEntity type:

public class PositionPipelineEntity
{
    // Only relevant to the TransformCoordinatesComponent 
    public decimal RawCoordinateLatitude { get; set; }

    // Only relevant to the TransformCoordinatesComponent 
    public decimal RawCoordinateLongitude { get; set; }

    // Required by all components after TransformCoordinatesComponent 
    public Coordinate CoordinateLatitude { get; set; }

    // Required by all components after TransformCoordinatesComponent 
    public Coordinate CoordinateLongitude { get; set; }

    // Set in DetermineCountryComponent, not required anywhere.  
    // Requires CoordinateLatitude and CoordinateLongitude (TransformCoordinatesComponent)
    public string CountryCode { get; set; }

    // Set in DetermineOnRoadComponent, not required anywhere.  
    // Requires CoordinateLatitude and CoordinateLongitude (TransformCoordinatesComponent)
    public bool OnRoad { get; set; }
}

Problems:

  • I’m very concerned about the dependency that a component has on properties. The way to solve this would be to create specific types for each component. The problem then is that I cannot chain them together like this.

  • The other problem is the order of components in the pipeline matters. There is some dependency. The current structure does not provide any static or runtime checking for such a thing.

Any feedback would be appreciated.

It appears to me as though your problem here might be partly that your pipeline is a little too abstract. It’s important to work with abstractions, but the openness of the design you have is making it hard for you to visualise the solution.

For example, with the order of components, you probably want to split these out in the pipeline, so that

pipeline
.RegisterComponent(new TransformCoordinatesComponent())
.RegisterComponent(new DetermineCountryComponent())
.RegisterComponent(new DetermineOnRoadComponent());

Might become something like

pipeline.TransformationCoordinates.Register(new TransformCoordinatesComponent());
pipeline.Determinations.Register(new DetermineCountryComponent());
pipeline.Determinations.Register(new DetermineOnRoadComponent());

Then your granularity becomes that of the number of different types of ordered component you need to have, so the Pipeline can have zero or many TransformationCoordinate components, Determination components and so on and will run all the ones available in order. Of course, this might be hidden inside pipeline.RegisterComponent splitting them out by interface, but this is an easier way to illustrate what I mean.

As you become less abstract you lose flexibility, in this case you would need to have a new collection if you added a new ordered type, so if you wanted to have an InvertComponent that ran between the TransformationCoordinate and the Determination components you would have to change your Pipeline accordingly. This is probably not a terrible thing, as long as your architecture is generally solid, however – you are likely to have to make the jump from the theoretical to the pragmatic at some point anyway.

Once you know the different component types you can guarantee that you have the correct properties available for each stage in the process- you could either ensure that the properties are set at each step on a type that always has them available or you could return a new object from each stage with the properties needed for the next.

Either way, I think you will find your work is easier if you start to think in more concrete terms about the exact processes you need to follow.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật