根据Martin Fowler的说法"有些东西可以公开,但这并不意味着你已经发布了它." 这是否意味着这样的事情:
public interface IRollsRoyceEngine
{
    void Start();
    void Stop();
    String GenerateEngineReport();
}
public class RollsRoyceEngine : IRollsRoyceEngine
{
    public bool EngineHasStarted { get; internal set; }
    public bool EngineIsServiceable { get; internal set; }
    #region Implementation of IRollsRoyceEngine
    public void Start()
    {
        if (EngineCanBeStarted())
            EngineHasStarted = true;
        else
            throw new InvalidOperationException("Engine can not be started at this time!");
    }
    public void Stop()
    {
        if (EngineCanBeStopped())
            EngineHasStarted = false;
        else
            throw new InvalidOperationException("Engine can not be started at this …我试图在Form2的另一个窗体上访问Form1的公共方法,如下所示.我textbox6对form1 有一个控件,并且有绑定它的公共方法.但是我想用form2绑定它,如下所示.
Form1中
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        Form2 f2 = new Form2();
        f2.Show();
    }
    public void amount_sum()
    {
        string connstr = " server=.;initial catalog=maa;uid=mah;pwd=mah";
        SqlConnection con = new SqlConnection(connstr);
        con.Open();
        string sql = " select sum(amount)as amount from method";
        SqlDataAdapter dap = new SqlDataAdapter(sql, con);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            textBox6.Text = …在java中,为了使我们的变量或方法公开,我们真的必须这样做吗?例如:
void aaa() {
...
}
要么
public void aaa() {
...
}
如果是必须的,为什么?
我们应该将pdo设置function __construct为private或public?如果我将它设置为易受攻击的主题public吗?
这是我的db类,
class pdo_connection
{
    public $connection; // handle of the db connexion
    public function __construct($dsn = 'mysql:host=localhost;dbname=xxx_2013',$username = 'root',$password = 'xxx')
    {   
    $this->dsn = $dsn;
        $this->username = $username;
        $this->password = $password;
        $this->connection();
    }
    private function connection()
    {
        try
        {
            $this->connection = new PDO($this->dsn, $this->username, $this->password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
            $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
        }
        catch (PDOException $e) 
        {
            # call the get_error function
            $this->get_error($e);
        }
        // return $this->connection;
    }
...
} …好的,奇怪的.我有许多带有转发器的用户控件,转发器的布局在所有控件中都是相同的,并且它们都有一个bindData()公共可用的方法.
我想知道,我可以设置另一个用于分页的usercontrol而不必指定父控件吗?
我能够做到以下几点:
((controls.specificuserControlClass)Parent).bindData();
这一切都很好 - 但是specificuserControlClass如果你明白我的意思,我需要指定进入寻呼机然后需要"每个转发器"吗?
我可以Parent.bindData()盲目地从孩子控制中打电话吗?我"知道"该方法存在(或将构建检查以确保),但是Visual Studio并不满意,因为它不知道该方法.
我遇到了私有构造函数的类,但是通过调用私有构造函数,该对象由另一个公共方法返回.当我们可以将构造函数公开时,这样的构造可能有什么优势?
public final class TokenTable {
    static public int errorToken = 0; 
    static public int timesToken = 1;
    static public int divToken = 2;
    static public int plusToken = 11;
    ......
    ......
    private final HashMap<String, Integer> keywordMap = new HashMap();
    private final HashMap<String, Integer> operationMap = new HashMap();
    private TokenTable() {
        operationMap.put("*", timesToken);
        operationMap.put("/", divToken);
        operationMap.put("+", plusToken);
        ....
    }
    static public TokenTable getInstance() {
            LexTokenTabInstance = new TokenTable();
            return LexTokenTabInstance;
    }
}
在一个名为Security的类中,有一个方法:
    public static bool HasAccess(string UserId, string ModuleID)
如何调用此方法,以便返回bool结果?
我尝试了跟进但没有成功:
    Security security = new Security();
    bool result = security.HasAccess("JKolk","Accounting");