How to organize all classes derived from SRP?

As the SRP says, the way to achieve this principle is divide all into smaller. And what you have just made small, make more smaller. As consequence we got more files and my question is about it, how organize all this new classes that are generated to keep our dirs clean, as the code.

For example. I’m developing an Android app on which I have a functionality about read a rss feed. It is invoked from different screens. It’s obvious that it is a responsibility but to achieve that, I have my sub responsibilities.

To read a RSS Channel I have to…:

  • Download XML file from URL.
  • Parse the XML file downloaded getting the channel details and all feed items.

So, I will have RSSChannelReader.java whose public method, something like read() will invoke NetworkRequest.java and RSSDocumentParser.java. As SOLID principles suggest interface segregation, I will use the interfaces INetworkRequest.java IRSSDocumentParser.java to operate.

Also, my RSSDocumentParser.java will use ChannelRSS.java and ChannelRSSFeedItem.java that works as vo for general channel description and feed items values.

So, I will have all this new classes: RSSChannelReader.java, INetworkRequest.java, IRSSDocumentParser.java, NetworkRequest.java, RSSDocumentParser.java, ChannelRSS.java, ChannelRSSFeedItem.java.

My app dir structure is:

  • Activities/: Contains the app screens.
  • Models/:
  • Business/:
  • Libs/:
  • […]

Then, where do I put all these new files? I supposed to put RSSChannelReader.java, IRSSDocumentParser.java,RSSDocumentParser.java, ChannelRSS.java, ChannelRSSFeedItem.java in business/RSSChannelReader. There is some problem if I mix the interfaces files with their implementations?

What about ChannelRSS.java, ChannelRSSFeedItem.java. Must be there on bussiness/RSSChannelReader or as they act as value object must be on models. I have to say that I work with them in the windows/screens of my app. Or maybe to create an adapter to transform the result object generated by my RSSChannelReader.java to my model object?

INetworkRequest.java and NetworkRequest.java should be in a different folder from business/RSSChannelReader.

My real problem, I think, is that some responsibilities, in this case ReadRSSChannel can produce other that can actuate as responsibilities for other responsibilities, for example my NetworkRequest. I can use to read rss but also could be useful for download images.

Do I have to create a new folder for each responsibility?

I’m a little confused because my project is increasing and some files aren’t place in the correct place. In some places my package name is too long with sub levels.

1

I am not an android developer but your question is generic enough so I will take a stab at it.

how organize all this new classes that are generated to keep our dirs
clean

In Java world you will be doing this by placing code in separate packages. For example in your case, you can create a package com.yourcompany.rss and place all files in there.

As long as com.yourcompany.rss package contents stick to SRP and define interface only for RSS parsing/consumption it is okay to mix interfaces with implementation. However, if in an app you get dozens of interfaces and implementation, you should consider sub-packages.

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