Skip to content

Ask HN: Question on Princples of DRY Programming

1 pointjk215discuss
On HN

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?

Comments

No comments yet.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.