Settings

Theme

Ask HN: Question on Princples of DRY Programming

1 points by jk215 15 years ago · 0 comments · 1 min read


Basically in the past Ive been a mostly front-end design/dev guy and Im making the leap into back-end. Right now Im working in the Codeigniter framework and my first project is coming along swimmingly. Im noticing that in my controllers I seem to be repeating some lines of code. Mostly related to determining if a user is logged in and serving them the proper views. Is that considered bad practice?

For example in my main controller I have an index function and a single entry function. Both functions have the same conditional checking if a user is logged in and showing the proper views. Would DRY only come into play while working in 1 function or would that someone apply to all the functions I create? If so, anything I should keep in mind to remedy that?

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection