Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

#9244 closed enhancement (wontfix)

extract methods from Ticket.save_changes() to improve readability

Reported by: felix.schwarz@… Owned by:
Priority: low Milestone:
Component: ticket system Version: 0.12dev
Severity: trivial Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I'd like to improve the readability of Ticket.save_changes() by extracting a few pieces of code into specialized private methods.

Attachments (3)

00_extract_component_ownership_setting (2.0 KB ) - added by Felix Schwarz <felix.schwarz@…> 15 years ago.
improve readability of Ticket.save_changes by extracting code to update owner on component update
00_extract_cc_list (1.4 KB ) - added by Felix Schwarz <felix.schwarz@…> 15 years ago.
improve readability of Ticket.save_changes by extracting code to sanitize the cc list
00_extract_ticket_attribute_saving (2.1 KB ) - added by Felix Schwarz <felix.schwarz@…> 15 years ago.
improve readability of Ticket.save_changes by extracting code to save changes in custom fields

Download all attachments as: .zip

Change History (8)

by Felix Schwarz <felix.schwarz@…>, 15 years ago

improve readability of Ticket.save_changes by extracting code to update owner on component update

by Felix Schwarz <felix.schwarz@…>, 15 years ago

Attachment: 00_extract_cc_list added

improve readability of Ticket.save_changes by extracting code to sanitize the cc list

by Felix Schwarz <felix.schwarz@…>, 15 years ago

improve readability of Ticket.save_changes by extracting code to save changes in custom fields

comment:1 by Remy Blank, 15 years ago

I'm not really convinced that this buys anything. Basically, you trade a comment for a method name. I would be more positive if the extracted methods were re-used elsewhere, but they are single-use methods. So in the current form, I'm rather -1.

in reply to:  1 comment:2 by Felix Schwarz <felix.schwarz@…>, 15 years ago

Replying to rblank:

I'm not really convinced that this buys anything. Basically, you trade a comment for a method name. I would be more positive if the extracted methods were re-used elsewhere, but they are single-use methods.

I'd like to make a point why methods are better than comments and why it does not matter if methods are re-used elsewhere:

  • When you read code, method calls are easier to skip things that you're not interested in because you don't have to look where the code block ends
  • methods make it more clear which input and output is expected, local variable names are less likely to clash
  • by moving code into a new method you keep methods short, therefore increase readability and decrease the likelihood of bugs

In a way short methods are the code equivalent to the Un*x philosophy "Write programs that do one thing and do it well".

comment:3 by Remy Blank, 15 years ago

Sure, I agree with the general idea. But it still bothers me when methods must be named _update_owner_if_component_changed_on_new_ticket() and _fix_cc_separators_and_remove_duplicates() to be understood, so in this specific context, I'd rather keep the code linear.

comment:4 by Christian Boos, 15 years ago

I agree with Remy, however what would work for me is going in the direction of a more generic save_changes, where the idiosyncrasies related to each field would somehow get abstracted away (see FieldRefactoring, substitute "render" with "save" or "normalize").

comment:5 by Remy Blank, 15 years ago

Milestone: 0.12
Resolution: wontfix
Status: newclosed

After deliberations, we think that there is too little value to split the save_changes() method.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.