dry

    0熱度

    1回答

    爲了儘可能保持我的應用程序視圖爲DRY,我遇到了一些問題。我的appliation.html.erb合併了一個靜態的側邊欄菜單。我的每個主控制器都包含一個輔助側欄菜單(本質上是一個子菜單)。我可以將呈現菜單的代碼從application.html.erb中提取出來,並將其放入每個視圖中,並在那裏更改次要邊欄,但這在我的視圖中會產生很多重複。 我看到這個SO post,看着this page,但我無

    2熱度

    2回答

    這是我的。 Map data = new HashMap<>(); // assume this has been populated public int getLastestVersion() { // data.get("PATH_TO_DESIRED_POINT") would be an integer return data.get("PATH_TO_DESIR

    1熱度

    2回答

    下面的代碼是用php編寫的switch語句。行$historical_term = $this->MonthlyCurves->getHistorical($term, $start_date, $end_date);在所有情況下重複。這違反了DRY(不要重複自己)的原則。有什麼方法可以改進代碼以堅持幹嗎? switch ($term) { case "1":

    6熱度

    2回答

    DRY方法在我urls.py我有一些條目這樣的: url(r'auftragsarten/list/$', generic.ListView.as_view( queryset=Auftragsart.objects.order_by('name'), paginate_by=25), name='auftragsarten_liste'), url(r'^au

    2熱度

    2回答

    我使用的連接表的解決方案,像這樣建立的友誼: class Contact < ActiveRecord::Base belongs_to :user belongs_to :friend, :class_name => "User", :foreign_key => :friend_id def self.request(user, friend) unl

    2熱度

    3回答

    我開始用下面的代碼(想象比這更多,但我認爲這一點對得到點): (defn fun1 [arg] {:fun1 arg}) (defn funA [arg] {:funA arg}) (defn funOne [arg] {:funOne arg}) (defn funBee [arg] {:funBee arg}) (defn -main [& args] (prn (fun1 "tes

    2熱度

    3回答

    在項目中,我的功能是這樣的: bool VectorList::put(const Pair &p); 這通過複製Pair添加Pair到VectorList。 我可以這樣使用它: Pair p { "key", "value" }; VectorList v; v.put(p); // or v.put(Pair{ "anotherkey", "anothervalue" });

    3熱度

    1回答

    正在調用d-tor內部移動賦值操作符的好習慣嗎? 這裏一些示例代碼: VectorList &operator = (VectorList &&other){ ~VectorList(); // if this is not a good practice, // I will need to paste whole d-tor here. _buffer

    -1熱度

    1回答

    兩個文件test_now.py和test_later.py如下: # test_now.py import unittest class CommonClass(unittest.TestCase): def hello(self): print "Hello there" def bye(self): print "Bye" def s

    0熱度

    1回答

    我得到了一個m × n維矩陣,我需要通過索引得到5個× 5維矩陣i,j。結果應該是這樣的: res = [[arr[i-2][j-2], arr[i-2][j-1]], arr[i-2][j ], arr[i-2][j+1], arr[i-2][j+2]] [arr[i-1][j-2], arr[i-1][j-1]], arr[i-1][j ], arr[i-1][j+1], arr[