Good style or bad style?

With these declarations...

type
   TItem = class
     Value : integer;
     constructor Create(aValue : integer);
   end;

   TItemList = class(TObjectList<TItem>)
     function A(anItem : TItem) : TItemList;
   end;

   procedure Q(L : TItemList);
   begin
      ...
     L.Free;
   end;

....we can write this:

   procedure P;
   begin
     Q(TItemList.Create
       .A(TItem.Create(1))
       .A(TItem.Create(2))
       .A(TItem.Create(3))
     );
   end;

Is it ''good'' style or ''bad'' style ;-)

Chris
0
Christian
3/12/2013 5:53:09 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

3 Replies
881 Views

Similar Articles

[PageSpeed] 10

Christian wrote:

> Is it ''good'' style or ''bad'' style ;-)

Bad.  If Q() raises an exception, the TItemList is leaked.  And if you do 
not Add() the TItem objects to the TItemList at all, or A() raises an exception 
before Add() can be called, they will be leaked as well.

--
Remy Lebeau (TeamB)
0
Remy
3/12/2013 6:21:17 PM
On Tue, 12 Mar 2013 10:53:09 -0700, Christian Aymon
<christian.aymon@icube.ch> wrote:

>With these declarations...
>
>type
>   TItem = class
>     Value : integer;
>     constructor Create(aValue : integer);
>   end;
>
>   TItemList = class(TObjectList<TItem>)
>     function A(anItem : TItem) : TItemList;
>   end;
>
>   procedure Q(L : TItemList);
>   begin
>      ...
>     L.Free;
>   end;
>
>...we can write this:
>
>   procedure P;
>   begin
>     Q(TItemList.Create
>       .A(TItem.Create(1))
>       .A(TItem.Create(2))
>       .A(TItem.Create(3))
>     );
>   end;
>
>Is it ''good'' style or ''bad'' style ;-)
>
>Chris

This is bad in any language that doesn't garbage collect.
0
Loren
3/12/2013 9:20:30 PM
It is also obscure, which is always bad....unless it is C++, when it would be expected :-)


> {quote:title=Christian Aymon wrote:}{quote}
> With these declarations...
> 
> type
>    TItem = class
>      Value : integer;
>      constructor Create(aValue : integer);
>    end;
> 
>    TItemList = class(TObjectList<TItem>)
>      function A(anItem : TItem) : TItemList;
>    end;
> 
>    procedure Q(L : TItemList);
>    begin
>       ...
>      L.Free;
>    end;
> 
> ...we can write this:
> 
>    procedure P;
>    begin
>      Q(TItemList.Create
>        .A(TItem.Create(1))
>        .A(TItem.Create(2))
>        .A(TItem.Create(3))
>      );
>    end;
> 
> Is it ''good'' style or ''bad'' style ;-)
> 
> Chris
0
Trevor
3/13/2013 10:01:34 PM
Reply:

Similar Artilces:

Styles or not to styles?
Scenario is as follows:I use align="center" in a DIV tag to, well, align content to the center.  But when running the page I get a warning saying that align is outdated.  So I'm thinking that styles is a better way to go.I remove align from the DIV tag and go for the equivalent style in styles - something like: styles="text-align: center;" - don't remember the exact format now but then I use Web Deveoper to set styles so it should be no syntax error.Anyway, running the page in Internet Explorer 8 and I get no center align what so ever.  It'...

Style
Hi, Is it possible to change the foreground/background of some words from a text from a TextCtrl control without re-writing the whole text? I am thinking to change the background of the words which I move the mouse cursor over, but if I would need to re-write the whole text, I think the text might flicker if the user will move the mouse very fast... Thanks. Octavian ...

style
    HI I want to show the following  in HTML page  What can be the style . Please help REgardsKaran RegardsKaran GuptaFor .net,Javascript and Sql server articles and interview question visithttp://guptakaran21.googlepages.com/main You will need to use pseudo-selectors. See this example: http://www.w3schools.com/CSS/tryit.asp?filename=trycss_firstletter  There are various ways to do this. Have a look here:http://www.mandarindesign.com/dropcaps.html  ...

Style
Name: Gabriel Rheault Email: leirbag666atgmaildotcom Product: Firefox Summary: Style Comments: I think that the style of firefox could be better, but for everythinf else, Good job Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3 ...

Style
Name: Tealsteam Email: tealsteam_at_hotmail.com Product: Minefield Summary: Style Comments: i like the new GUI on the tab bar it seems to help me alot as i do alot of design work, and comunity work for online gaming, so i have to switch between sites all the time, also the new spell checker works well as it helped me to peice this detailed comment together with correct spellings, and well the choices on the search bar between google, yahoo ect, is pretty neat as i can say this is a really nice beta, just 1 thing i was thinking about last night, lets say your on a page and you hit ...

style
Name: tom Product: Firefox Release Candidate Summary: style Comments: I think the main icons on the new firefox 3.0 look i little bit cheap, like internet explorer. And that is 1 of the reasons i use firefox in stead of internet explorer Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9) Gecko/2008051206 Firefox/3.0 From URL: http://hendrix.mozilla.org/ ...

style.display vs style.visibility
Hi i have javascript code as document.getElementById("trState").style.display = 'block';which works fine in IE, but not working in FireFox.For FireFox i have to change the code as document.getElementById("trState").style.visibility = 'visible'; And it is working fine in FireFox. But the problem is, the second code is generating empty rows containing hidden elements. So how can i get around this problem. Is there any way that will ouput and work in same manner in both browser. thanx in advance   Which version of IE and Firefox are u using?...

CSS style
Hi,I have this link on a web page.  <A class="LinkStyle" href="">Some Text</A>The link was displayed correctly, like what I specified under 'LinkStyle'. I added a reference to an external CSS file, we have no control over this. This file has a generic style for links, like this a:link, a:visited, a:active, a:hover { text-decoration: underline; color: #123456; }And this is screwing up the 'Some Text' link. If I save this external css file locally and comment out the generic anchor styles, that fixes my problem. (I don't have acc...

Convert HTML styles to style objects ?
I have looked and looked but cannot find any code that will convert an HTML or CSS style to a Style object (System.Web.UI.WebControls.Style)I have a database that contains thousands of user-defined styles that need to be converted to style objects to be used on the server side.I am currently trying to write a conversion but the list of individual things to convert is growing and growing.Does anyone have an easy method?ThanksMatRegardsMatthew ...

Applying style sheet styles to master page
Hi,I've a a site with nested master pages and content pages. I tried using a theme with a stylesheet in the app_themes directory referencing it in the web.config file from a pages tag theme attribute. This works for the content pages, but it doesn't seem able to apply the styles to the top master page even though I did set the master head tag to runat server. Is this by design? If so, what is the best way to apply styles to the top master page content? What did work for me was to add a style sheet link in the master page header but this doesn't seem to be a very elegant solution to...

Edit Styles for Datetimes not showing up in Style Choices
There is an edit style called std_date in the edit styles list. I bring in a query from an Oracle 7 database that has several datetime columns. When I go to pick the style name the even numbered (in Column Specifications) datetime columns will not list the datetime edit styles. example: Select field1, datetime1, datetime2, field2, datetime3, datetime4 .... datetime1 and datetime4 will not have the std_date or any other datetime formats listed in the style names. Yet datetime2 and datetime3 do. The ones that are on odd numbers in the column specification will allow datetime style ...

Styles
Hi I am trying to apply some styles to my controls. Is there a place where I can get sample css definition for controls. Thanks take a look at my blog post http://peterkellner.net/2006/08/28/msprofcsshowto/ it has a reference to some microsoft standard themesPeter Kellnerhttp://73rdstreet.com and blogging athttp://PeterKellner.netMVP, ASP.NET Hi, You can this MSDN article, you can download these Design Templates css style.   Hope it helps.Amanda WangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide n...

with a style,...
Name: arpisces@gmail.com Email: arpiscesatgmaildotcom Product: Minefield Summary: with a style,... Comments: give me more information,..... Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a6pre) Gecko/20100621 Minefield/3.7a6pre From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

styles
hi, i crated the msword document.....in the footer i need the page no like this page x of y..(ex page 1 of 5)..in the footer it os coming it is good......... but in the header and only in the first page....it is coming like this     "page 1 of "  how can i delete this ,,,, just i used the following code for this oStringWriter.Write("<div style='mso-element:footer' id=f1>" + " <p class=MsoFooter>" + " <span style='mso-tab-count:2'></span>Page <span style='mso-field-code: PAGE '&...

Web resources about - Good style or bad style? - embarcadero.delphi.general

Wikipedia talk:Manual of Style/Canada-related articles - Wikipedia, the free encyclopedia
This page is within the scope of WikiProject Canada , a collaborative effort to improve the coverage of Canada on Wikipedia. If you would like ...

Turkish leader's office denies advocating Hitler-style rule
President Recep Tayyip Erdogan's office issues statement after leader makes reference to Hitler's Germany

Kendall Jenner & Harry Styles are vacationing together in Anguilla for NYE
... for very long – in just the past few months, she’s been rumored to be dealing with Lewis Hamilton, Orlando Bloom, Joe Jonas and Harry Styles. ...

Open thread for night owls. Ta-Nehisi Coates: 'The paranoid style of American policing
Ta-Nehisi Coates at The Atlantic writes— The Paranoid Style of American Policing : When I was around 10 years old, my father confronted a young ...

Is Gap Losing Its Style?
While Gap has not yet declared its December sales numbers, it appears that it is continuing its losing streak in the holiday season. FBR capital ...

These Nerdy Moments Remade In the Style of Classic Paintings Are Beautiful
Amateur photographer Pekka Jonsson uses a very tight budget to remake the old iconography of martyrs and saints into something much, much geekier. ...

[PICS] Harry Styles & Kendall Jenner Vacation In Anguilla: Exes Reunite - Hollywood Life
OMG, you guys, wait until you hear about this amazing reunion of two famous exes! Kendall Jenner and Harry Styles were caught on vacation together ...

Style Notes: Carrie Fisher Shuts Down Body Shamers; North West Rocks $3500 Fur ...
Hollywood Reporter Style Notes: Carrie Fisher Shuts Down Body Shamers; North West Rocks $3500 Fur ... Hollywood Reporter Twitter trolls have ...

Kanye West GQ’s Most Stylish Man Of 2015: Yeezy’s Style Is Not For Kids Though
... men’s magazine, the rapper walked away with the most votes since he came up against model Lucky Blue Smith. And that’s because West has a style ...

Kendall Jenner & Harry Styles Get Cozy, Flaunt PDA in St. Barts
Kendall Jenner and Harry Styles share a smile as they cozy up while aboard a private yacht on Wednesday (December 31) in St. Barts. The 20-year-old ...

Resources last updated: 1/2/2016 6:54:30 AM