2

Lets take this question as an example because I am fed up of understanding stereotype examples.

A newspaper company is planning to develop a new software system for managing different news articles written by its own journalist and news sources taken from different news organizations.

The different articles are displayed in different formats and arrangements to the readers. The online news website of the company shows the latest news articles in its main front page. Here the beading and a summary of the news article is shown. An RSS feed of the site shows the heading and brief summary of the main news articles in XML format. The users in both cases can click the heading to see the complete article.

The digital version of the newspaper contains the full articles formatted according to a traditional news paper.

A Junior Software Engineer is currently designing the new software system for this newspaper company. He has designed a class to represent a news article. Each object of this class will represent one news article i.e. its heading, authors, category, brief description, full article etc.

In all of the three scenarios (online newspaper. RSS feed, digital newspaper) objects of the news article class will be used to display the content.

Now according to my view,

Extrinsic - heading, authors

Intrinsic - category

Is this correct? Or is there a way to identify these states effectively?

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
Gayan Jayasingha
  • 752
  • 2
  • 17
  • 33
  • Are you sure flyweight is good pattern for this (or is it somehow a must)? Is handling full article objects a problem you are solving? I do not think category is intrinsic... Intrinsic means shareable and what are you going to achieve by sharing categories? I fail to see enough justification for flyweight here. – Roman Susi Oct 09 '13 at 17:49
  • This was actually one of my final exam questions. At the end of the question there is another sentence which says."A Senior Software Engineer who has reviewed this design has suggested that the Flyweight software design can be used for this solution." – Gayan Jayasingha Oct 09 '13 at 17:54

1 Answers1

0

The only way I can see flyweight pattern can be beneficial in this setting is when shareable representational aspects are made intrinsic, and almost everything belonging to an article data/metadata is extrinsic. This means, category, being article metadata (if I understood correctly) should not be intrinsic. But it is probably bad thing to combine representation and core object in one class anyway, so breaking into "view class" and "content class" is naturally there (not even sure it can be considered as applying flyweight pattern).

In other words, different factories for feed items, page items, etc, which you manipulate.

Also, it's usually a case certain article representation requires less metadata, than full article representation (for example, feeds usually do not use full text of the article or article layout peculiarities). This leads to using some other architectural possibilities, if full persistent object manipulation is slower than, say, lightweight proxy objects, which have just enough metadata to render feeds, lists and such.

The situation is somewhat abstract to make architectural decisions. For example, how queries are implemented? What they return? So this may be good for exam question (as the context is limited to specific course), but in real life there are much more considerations.

Roman Susi
  • 4,135
  • 2
  • 32
  • 47