用于创建“值对象”(VO)对象的内部类(Inner Class to Create a “value object” (VO) Object)
将内部类用作VO是不好的做法,因此代码可以清晰
EX:在将数据存储到文件中之前,我必须修改一些值。 我创建了一个VO类,以便将来需要修改它时,它可以很容易读取。
此操作过程将仅在此类中执行,并且我生成的VO将不会在任何其他位置使用。 那么在这种情况下创建内部类并使用它更好吗? 做那样的事情是不好的做法? 会创建内部类并将它们用作VO引起任何安全问题吗?
is it a bad practice to use a inner class as a VO so the code can be clear
EX: I have to modify some values before storing the data in a file. I have created a VO Class so that If someone else needs to modify it in future , it could be easily readable.
This process of operation will be performed only in this class and the VO that I generated will not be used in any place else. So In that case is it better to create a inner Class and use it ? would it be bad practice to do something like that ? would creating inner class and using them as VO cause any security concerns ?
原文:https://stackoverflow.com/questions/43541492
最满意答案
相关问答
更多-
运行rake任务(running rake task)[2023-04-27]
嗨你可以编写你的任务,然后写一个新的,它将调用两个单独的任务 - 运行测试和你的task :run_all => ['db:test:clone ', 'db:test:prepare ', 'test:units', :your_task]类似task :run_all => ['db:test:clone ', 'db:test:prepare ', 'test:units', :your_task] Hi You may write your task an then write new one th ... -
尝试在代码中设置ENV变量: task :diagram do ENV['filetype']='dot' ENV['disconnected'='true' Rake::Task['erd'].invoke end Try setting the ENV variables in your code: task :diagram do ENV['filetype']='dot' ENV['disconnected'='true' Rake::Task['erd'].invok ...
-
为什么我的rake任务通过CLI成功,但在“每当”(Why does my rake task succeed through CLI but fail when run through “whenever”)[2023-06-15]
尝试在schedule.rb中设置环境变量: # config/schedule.rb: set :chronic_options, :hours24 => true set :output, "log/cron_log.log" env :PATH, ENV['PATH'] env :TRELLO_API_KEY, ENV['TRELLO_API_KEY'] env :TRELLO_CLIENT_SECRET, ENV['TRELLO_CLIENT_SECRET'] every 1.minute do ... -
Rake任务在命名空间之外(Rake task outside of namespace)[2022-01-03]
该行将puts "I'm in setup"不是任何任务的一部分 - 它将在您正在解析文件时执行您指定的任何任务(甚至是不存在的任务)(严格地说,当Ruby解析文件时不会执行该任务,但是正在执行并设置rake任务): $ rake foo I'm in setup rake aborted! Don't know how to build task 'foo' (See full trace by running task with --trace) 只有在文件被读取后才会执行任务查找,这就是引用的内容 ... -
耙“变量”任务(Rake “variadic” task)[2023-11-26]
版本0.8的Rake无法处理这个问题,正如其文档中所述(它只是忽略了任何其他参数)。 但是,如果您可以切换到使用Thor ,则可以获得此行为。 要演示, Thorfile使用以下内容创建Thorfile : class VariableArguments < Thor desc 'multiple [ARGS]', "Task with multiple arguments" def multiple(*args) p args end end 然后像这样调用它: $ thor var ... -
Rake自动加载Gemspec(Rake autoloading Gemspec)[2022-03-31]
Rake只是ruby代码,所以除非你没有使用某种其他的gem来以某种方式操纵你的简单rake命令。 你不应该加载gemsec文件! 我在github上的rake存储库中搜索了这个$ global变量并没有找到任何结果。 这里 如果您认为自己正在做可能影响自然红宝石代码的事情,请更新问题。 Rake is just ruby code, so unless you are not using some other gem that somehow manipulates your simple rake co ... -
我需要在我的rake任务中添加:environment task :my_task => :environment do # do work end 我还添加了followind行: config.dependency_loading = true 在production.rb文件上 I needed to add :environment on my rake task task :my_task => :environment do # do work end i also add th ...
-
是否有FTP的Rake任务?(Is there a Rake task for FTP?)[2022-10-03]
好吧,我决定自己做。 代码不是很漂亮,因为它包含了很多异常处理,但它完成了工作:) require 'rake' require 'net/ftp' def ftp_files(prefixToRemove, sourceFileList, targetDir, hostname, username, password) Net::FTP.open(hostname, username, password) do |ftp| begin puts "Creating dir #{targe ... -
我正在使用Rails 3.2,所以我无法使用Active Job。 我用Sidekiq并且工作正常。 在这里查看非常有用的教程 I am using Rails 3.2, so I couldn't use Active Job. I used Sidekiq and worked fine. Check a very helpful tutorial here
-
添加子任务rake(Add sub-task rake)[2022-04-06]
使用namespace指令: namespace :db do namespace :seed do task :demo do end end end Use the namespace directive: namespace :db do namespace :seed do task :demo do end end end